Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug Why does the -quit CLI option prevent tests from running?

Discussion in 'Testing & Automation' started by Xarbrough, Nov 11, 2022.

  1. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,173
    I've followed the instruction on how to run tests from the command line. This worked fine initially, but then I added the
    -quit
    argument because it sounded like I need to tell Unity to quit once its done after reading the doc page about editor command line arguments.

    The docs are not very clear on this: What does the -quit argument really do? And why does it prevent test from running?

    I double checked multiple times, without the additional argument I see log statements like this:
    And can also see my TestResults.xml file appear.

    But with the quit argument added, there are no log statements indicating a test run and no TestResults file created. Unity simply starts, imports, then shuts down.

    If this behaviour is not considered a bug, I believe it should be made clear how to use it in the docs, please!
     
  2. R2-RT

    R2-RT

    Joined:
    May 8, 2019
    Posts:
    38
    I am writing out of my head, I hope that also correctly.

    To put is simply -quit makes Unity Editor exit after importing project and executing first editor update frame.
    It is meant to be used with -executeMethod, to make Editor exit after doing stuff (e.g. executing custom build command).

    For example, if you start Editor on some project with only -executeMethod XYZ, it will run XYZ and leave Editor process/window open. I don't rembemer how -batchmode changes that but probably leaves dangling process as well.

    UTF implementation detects when it is run via command line and manually closes the editor process once tests are finished (see UnityEditor.TestRunner\CommandLineTest\Executer.cs).

    But if you pass both -runTests and -quit you don't give any time for executer to actually run tests. -quit closes the process after first frame. So you see in logs tests are starting, tests results get created (for all finished tests, that is nil).