Search Unity

Question RetrieveTestList & Test Callbacks do not work in methods executed from command line

Discussion in 'Testing & Automation' started by fipsy, Jan 17, 2021.

  1. fipsy

    fipsy

    Joined:
    Sep 3, 2016
    Posts:
    15
    The setup:
    • calling BatchModeMethod from the command line (-executeMethod)
    BatchModeMethod looks something like this:
    Code (CSharp):
    1. public static async void BatchModeMethod()
    2.         {
    3.             Debug.Log("Inside BatchmodeMethod");
    4.             var api = ScriptableObject.CreateInstance<TestRunnerApi>();
    5.             api.RetrieveTestList(TestMode.EditMode, adaptor =>
    6.             {
    7.                 Debug.Log("inside retrieveTestList callback");
    8.             });
    9.  
    10.             var startTime = DateTime.Now;
    11.             while ((DateTime.Now - startTime).TotalSeconds < 10)
    12.             {
    13.                 await Task.Yield();
    14.             }
    15.             Debug.Log("Waited for: " + (DateTime.Now - startTime).TotalSeconds + "sec");
    16.         }
    The result
    • the first and last logs are logged correctly, indicating that the method is called correctly and waits for 10sec before finishing
    • BUT "inside retrieveTestList callback" is never logged, so the callback is never called.
    • the same happend when you try to get callbacks from tests run this way
    • BatchModeMethod works without problems if you run it in a manually started editor instance
    So my question: how can I make the callbacks work in methods and editors called from commandline?
     
  2. zepplock

    zepplock

    Joined:
    Feb 23, 2019
    Posts:
    1
    I see the same behavior. @fipsy was this ever resolved for you?
    Although my tests are PlayMode, I get no callback from command line as well.