Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Null Ref Exception thrown by UnityEnginer's PlaymodeTestsController

Discussion in 'Testing & Automation' started by wpatel, Feb 28, 2020.

  1. wpatel


    Sep 27, 2018
    Has anyone seen this exception before?
    I was running all my PlayMode tests when they ended early with this error.

    NullReferenceException: Object reference not set to an instance of an object
    UnityEngine.TestTools.TestRunner.PlaymodeTestsController+<TestRunnerCoroutine>d__15.MoveNext () (at Library/PackageCache/com.unity.test-framework@1.1.3/UnityEngine.TestRunner/TestRunner/PlaymodeTestsController.cs:74)

    All tests pass individually or in their suites.
    But running as a large group by selecting all and running causes this error.
    It keeps breaking after the same number of tests so the error is consistent.
    I tried deleting the Library folder but no luck.

    It's never happened before.
    I did make a change to one of my tests but:
    1. The method signature is the same. Iow, it's not the UnityTest with void return versus Test with IEnumerator return error
    2. The change only had to do with the removal of an Assert so I'm not sure what caused it.
    3. This test runs to completion sucessfully and additional test suites are ran afterwards.

    But it does have something to do with my code changes apparently, because the exception does not occur on my develop branch, only the one with my changes.
  2. wpatel


    Sep 27, 2018
    As an update to this..
    Is there a max number of frames the test runner is willing to process?
    Long story short, my test had a loop waiting for a variable to change which has it's maxFrame count set to 1000.
    I dropped it down to 100 and the exception is gone...

    [Update] As far as I can tell, this is definitely not caused by a code change.
    I cloned the branch into another directory structure and I don't see the problem.
    Last edited: Mar 2, 2020