2

I want to know, how do i test OnMouseDown() function (Or any Event based function) for integration testing using unity test tools.

I attached CallTesting.cs script on cube who will get OnMouseDown() event. I have to test this functionality by using Unity Test Tools(Integration Test Tool). So please give me some guidance how do i achieve this?

Thanks in Advance.

Sarthak mirajkar
  • 191
  • 1
  • 1
  • 7
  • 1
    I disagree with the reason for the close vote ("too broad") because this is a very specific question: How *does* one unit test the Unity built-in MonoBehaviour methods? I can't find any resources on it and this question pops up as the first hit. – Draco18s no longer trusts SE May 04 '17 at 13:47

1 Answers1

0

Sorry to necro, but I had the same question and found a simple solution.

You can change the access modifier to public and call OnMouseDown() in your test.

Other events such as OnCollision would require you to pass through mock collision information when testing.

Lance
  • 1