docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Namespace UnityEditor.TestTools

    Classes

    RequirePlatformSupportAttribute

    The RequirePlatformSupportAttribute attribute can be applied to test assemblies (will affect every test in the assembly), fixtures (will affect every test in the fixture), or to individual test methods.

    TestPlayerBuildModifierAttribute

    You can use the ```TestPlayerBuildModifier``` attribute to accomplish a couple of different scenarios. ## Modify the Player build options for Play Mode tests

    It is possible to change the BuildPlayerOptions for the test Player, to achieve custom behavior when running Play Mode tests. Modifying the build options allows for changing the target location of the build as well as changing BuildOptions.

    To modify the BuildPlayerOptions, do the following:

    • Implement the ITestPlayerBuildModifier
    • Reference the implementation type in a TestPlayerBuildModifier attribute on an assembly level.
    using UnityEditor;
    using UnityEditor.TestTools;
    

    [assembly:TestPlayerBuildModifier(typeof(BuildModifier))] public class BuildModifier : ITestPlayerBuildModifier { public BuildPlayerOptions ModifyOptions(BuildPlayerOptions playerOptions) { if (playerOptions.target == BuildTarget.iOS) { playerOptions.options |= BuildOptions.SymlinkLibraries; // Enable symlink libraries when running on iOS }

        playerOptions.options |= BuildOptions.AllowDebugging; // Enable allow Debugging flag on the test Player.
        return playerOptions;
    }
    

    }

    > **Note:** When building the Player, it includes all `TestPlayerBuildModifier` attributes across all loaded assemblies, independent of the currently used test filter. As the implementation references the `UnityEditor` namespace, the code is typically implemented in an Editor only assembly, as the `UnityEditor` namespace is not available otherwise.

    Split build and run

    It is possible to use the Unity Editor for building the Player with tests, without running the tests. This allows for running the Player on e.g. another machine. In this case, it is necessary to modify the Player to build and implement a custom handling of the test result. By using TestPlayerBuildModifier, you can alter the BuildOptions to not start the Player after the build as well as build the Player at a specific location. Combined with PostBuildCleanup, you can automatically exit the Editor on completion of the build.

    Interfaces

    ITestPlayerBuildModifier

    An interface for a callback modifying the UnityEditor.BuildPlayerOptions when building a player for running tests in the runtime.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)