Search Unity

Resolved Unit Test Runner Window does not detect TestFixtures

Discussion in 'Testing & Automation' started by MNNoxMortem, Jul 16, 2017.

  1. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    The Unit Runner Test Window says I have no TestFixtures. This is also printed to the debug log which is bad. However: Obviously I do have TestFixtures and I am able to run them from the Test Runner Window.

    Manually running it with:
    Unity.exe -batchmode -testPlatform playmode -projectPath <projectPath> -runTests -testResults <projectPath>\testResultIntegration.xml

    Also seems to work. However, I do get the following errors::
    * One or more child tests had errors
    * Assembly-CSharp-firstpass.dll Has no TestFixtures

    If i create an additional playmode test over the context menu inside of Assets/Editor then it displays that both assemblies have tests, altough the editor tests can not be run anymore, but the playmode tests then seem to work.
     

    Attached Files:

    Last edited: Jan 27, 2019
  2. broersma

    broersma

    Joined:
    Apr 30, 2015
    Posts:
    11
    If you have "Plugins", "Standard Assets" or "Pro Standard Assets" in your Assets folder, then a Assembly-CSharp-firstpass.dll will be built (source). Although it won't contain any tests (unless you put some in one of those folders), it will be contained in the test suite for your Unity project when trying to run playmode tests from the Unity Test Runner or from the command line like so:

    Unity.exe -projectPath <projectPath> -batchmode -runTests -testPlatform playmode -testResults <projectPath>\testresults.xml

    Because of this you will get the "One or more child tests had errors" error in the Unity Test Runner or in your testResults file. This is caused by the "Has no TestFixtures" error from the (normally spurious) test suite execution of the Assembly-CSharp-firstpass.dll.


    To fix this you can specify -testFilter which filters based on the fullname-attribute of any test-suite- or test-case-element that appears in the testResults file. More specifically you would want to add the following to the above command line:

    -testFilter "<projectPath>/Library/ScriptAssemblies/Assembly-CSharp.dll"

    This way only your playmode tests that are not contained in the "Plugins", "Standard Assets" or "Pro Standard Assets" in your Assets folder (all of them?) will be executed.
     
    Last edited: Sep 29, 2017
    benbenmushi and MNNoxMortem like this.
  3. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    Thanks!
     
    broersma likes this.
  4. benbenmushi

    benbenmushi

    Joined:
    Jan 29, 2013
    Posts:
    34
    Hi folks,

    In addition to that note that on windows:
    The parameter -testFilter uses "Unix Shell" path style with / directory separator instead of \
    This might be confusing because your others arguments like -projectPath or -testResults uses Windows style path (which accept both \ and /)
     
    MNNoxMortem likes this.
  5. raincole

    raincole

    Joined:
    Sep 14, 2012
    Posts:
    63
    Sorry for bumping this old thread, but does anyone know how to set -testFilter for Unity Cloud Build? I got the similar problem but it only happened on Unity Cloud Build.