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

Question PlayMode Tests never stopping in Editor

Discussion in 'Testing & Automation' started by Alanyeats, May 19, 2023.

  1. Alanyeats

    Alanyeats

    Joined:
    Feb 20, 2016
    Posts:
    23
    I've been using EditMode tests for a while and wanted to just quickly setup a set of Playmode test but hit a weird issues where PlayMode test just don't work in editor.

    using a default test bellow and pressing run all

    Code (CSharp):
    1.  
    2.         [UnityTest]
    3.         public IEnumerator Tests()
    4.         {
    5.             yield return null;
    6.         }
    it will just boot into given scene but will just never stop playing thus never show pass or fail. I'm at a bit of a loss on why this would be occuring.
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    7,009
    What versions of Unity and Test Framework?

    What happens if you only use a [Test] method without yield?

    Did you try creating an empty (new) scene and open that before launching the playmode tests? I can imagine that something in the scene might interfere with playmode tests.
     
  3. Alanyeats

    Alanyeats

    Joined:
    Feb 20, 2016
    Posts:
    23
    Will leave this thread up for propteraty but it was 100% on my end due to the use of a InitializeOnLoad class hooking into our scene managment. Which we just didn't want to use in test mode. Disabling that while running unit test fixed the issue