Error when using BuildOptions.IncludeTestAssemblies and InputTestFixture

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:

Library/PackageCache/com.unity.inputsystem@1.0.0/Tests/TestFixture/InputTestFixture.cs(89,29): error CS0117: 'InputSystem' does not contain a definition for 'SaveAndReset'
Library/PackageCache/com.unity.inputsystem@1.0.0/Tests/TestFixture/InputTestFixture.cs(132,29): error CS0117: 'InputSystem' does not contain a definition for 'Restore'
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:

BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
buildPlayerOptions.scenes = new[] { "Assets/Scenes 1/Init.unity"};
buildPlayerOptions.locationPathName = "../builds/GCBuild/GCBuild";
buildPlayerOptions.target = BuildTarget.StandaloneLinux64;
buildPlayerOptions.options = BuildOptions.IncludeTestAssemblies;

BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions);

Am I missing something? Do I need to use additional BuildOptions?

If you look at line 2919 in the InputSystem code, you will see:

#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.

That was it! I added BuildOptions.Development and it worked.

Thanks for your answer @superpig .

1 Like