JetBrains / resharper-unity

Unity support for both ReSharper and Rider
Apache License 2.0
1.21k stars 134 forks source link

[Tests] When using Unity's attributes -> use IEnumerator #1526

Open MeikelLP opened 4 years ago

MeikelLP commented 4 years ago

With Unity's test framework there is an attribute UnitySetUp which are equal to the normal SetUp from NUnit except that this will be called from Unity as a coroutine. So we must declare it as IEnumerator.

The same goes for UnityTearDown & UnityTest.

Would be lovely if Rider would warn you about that because Unity will throw an exception if the method is a void... A quick fix would be awesome too :)

Reference:

valorieschwartzdev commented 4 years ago

Jesus christ, I'm glad I found this cause I was pulling my hair out trying to figure out why UnitySetUp and UnityTearDown attributes weren't working. It's not even throwing an exception, it just doesn't call the methods at all.