Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PlayMode tests stopping by default if errors are logged in scripts

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?

like image 379
Alexandru Avatar asked Oct 17 '17 20:10

Alexandru


2 Answers

Disable Error Pause on the Console tab. This should prevent Debug.LogError from pausing your Game.

enter image description here


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;
like image 107
Programmer Avatar answered Nov 15 '22 02:11

Programmer


To allow all Error messages you can set LogAssert.ignoreFailingMessages to true.

like image 25
Jethro Avatar answered Nov 15 '22 02:11

Jethro