Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Bug Units tests not working at all (TestRunner)

Discussion in 'Testing & Automation' started by Wrymnn, Dec 7, 2023.

  1. Wrymnn

    Wrymnn

    Joined:
    Sep 24, 2014
    Posts:
    388
    So for some reason, when running unit tests, they do not "work", the unit test code runs fine, even asserts run and execute, because I have added logging to the test methods.

    The test scene is started, tests run, and then nothing, the play mode stays as is and there is no further action from the TestRunner.

    upload_2023-12-7_10-5-17.png
    You can see, the unit test does not fail nor complete, but if you look at console, the code has executed just fine.

    Code (CSharp):
    1. public class LootSpawnerTests
    2. {
    3.     [UnityTest]
    4.     public IEnumerator WeightedLoot_NoLoot()
    5.     {
    6.         Debug.Log("a");
    7.         yield return null;
    8.         Debug.Log("b");
    9.         yield return null;
    10.         Assert.True(true);
    11.         Debug.Log("c");
    12.     }
    13. }
    - using Unity 2022.3.14 LTS
    - using 1.1.13 Test Framework package
    - tried restarting editor several times
    - tried EditMode tests, they seem to run fine, only PlayMode tests have this issue
    - tried even with single yield return null, did not help
    - tried using Assert.

    Another showcase of more tests, these ones were working year back, you can see play mode is just sitting there
    upload_2023-12-7_10-11-23.png
     

    Attached Files:

  2. irene_reko

    irene_reko

    Joined:
    Feb 14, 2019
    Posts:
    12
    Is the editor paused because there are exceptions? The second screenshot shows a few errors. I would look into these first.
     
  3. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    7,000
    Any reason why your testrunner package is this old? I currently use 1.3.9 and this works even in 2021.3 projects.
     
  4. Wrymnn

    Wrymnn

    Joined:
    Sep 24, 2014
    Posts:
    388
    Indeed I had old version, not sure why is that, as package manager was not showing me any possible upgrade. Not it works.

    upload_2023-12-8_10-24-22.png

    so I manually had to modify manifest.

    Also, any idea why are tests generating bunch of scene assets under Assets? Any way how to turn this off?
    upload_2023-12-8_10-25-1.png
     

    Attached Files:

  5. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    7,000
    You may have some other (older) package that depends on that particular Test Framework package version.

    You may want to check what other package this could be. See the Test Runner dependencies tab and then look for updates for the packages listed as depending on Test Framework.