Empirically, I can see that Unity stops running a PlayMode test if any error log is created programmatically when a script calls Debug.LogError
.
This is a problem for me because I would like PlayMode tests to only stop on assertion failures.
Is there any way to tell Unity not to stop the current PlayMode test if an error is logged?
Disable Error Pause on the Console tab. This should prevent Debug.LogError
from pausing your Game.
If this test is not done in the Editor then it will fail. To prevent that, immediately call LogAssert.Expect
after Debug.LogError
to prevent Unity from stopping or the test from failing when Debug.LogError
is called.
Debug.LogError("Your Error");
LogAssert.Expect(LogType.Error, "Your Error");
Edit:
In Unity 2017 and above, you can now use LogAssert.ignoreFailingMessages
to accomplish that by setting it to true. You can still use the answer above for older Unity version.
LogAssert.ignoreFailingMessages = true;
To allow all Error messages you can set LogAssert.ignoreFailingMessages to true.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With