Search Unity

Question Error when using BuildOptions.IncludeTestAssemblies and InputTestFixture

Discussion in 'Testing & Automation' started by Minitrope, Oct 4, 2020.

  1. Minitrope

    Minitrope

    Joined:
    May 21, 2020
    Posts:
    4
    Hello,

    I'm trying to use BuildOptions.IncludeTestAssemblies to make a custom build including my tests.
    Unfortunately, I'm using InputSystem and during the build the following error occur at compile time:

    Code (csharp):
    1. Library/PackageCache/com.unity.inputsystem@1.0.0/Tests/TestFixture/InputTestFixture.cs(89,29): error CS0117: 'InputSystem' does not contain a definition for 'SaveAndReset'
    2. Library/PackageCache/com.unity.inputsystem@1.0.0/Tests/TestFixture/InputTestFixture.cs(132,29): error CS0117: 'InputSystem' does not contain a definition for 'Restore'
    3. Error building Player because scripts had compiler errors
    This is surprising to me since "running tests in player" from the test runner (which produces a build including the tests) works fine.
    I checked the code in the package cache as indicated by the error, and didn't find the mentioned methods, but when I looked at the code on github, those are present for the 1.0.0.0 tag.

    Here is the code I use to launch the build:

    Code (CSharp):
    1.  
    2. BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
    3. buildPlayerOptions.scenes = new[] { "Assets/Scenes 1/Init.unity"};
    4. buildPlayerOptions.locationPathName = "../builds/GCBuild/GCBuild";
    5. buildPlayerOptions.target = BuildTarget.StandaloneLinux64;
    6. buildPlayerOptions.options = BuildOptions.IncludeTestAssemblies;
    7.  
    8. BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions);
    Am I missing something? Do I need to use additional BuildOptions?
     
  2. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,659
    If you look at line 2919 in the InputSystem code, you will see:

    Code (CSharp):
    1. #if DEVELOPMENT_BUILD || UNITY_EDITOR
    meaning that you need to ensure you are specifying
    BuildOptions.Development
    as well, if you want to use those methods in your tests.
     
  3. Minitrope

    Minitrope

    Joined:
    May 21, 2020
    Posts:
    4
    That was it! I added BuildOptions.Development and it worked.

    Thanks for your answer @superpig.
     
    superpig likes this.