docs.unity.cn
    Show / Hide Table of Contents

    Class RequiresPlayModeAttribute

    Use this attribute to instruct the test framework to run tests in PlayMode or EditMode when run in the Editor, independent of the assembly configuration. The attribute can be applied to a single test method, a test fixture, or the whole assembly. If specified on multiple levels, the test follows the attribute on the lowest level. E.g. if the assembly has [RequiresPlayMode(false)], which runs all tests in EditMode, and the test fixture has [RequiresPlayMode], which runs all tests in PlayMode, then a test in that fixture will run in PlayMode, taking the configuration from the fixture. The attribute allows for two new combinations:

    • Editor-only tests that always run in PlayMode.
    • Tests that can run on platforms, but that run without entering PlayMode when run in the Editor.

    By default, any Editor-only assembly has the equivalent of [RequiresPlayMode(false)] applied, while an assembly with platform support has the equivalent of [RequiresPlayMode] applied.

    Inheritance
    Object
    RequiresPlayModeAttribute
    Namespace: UnityEngine.TestTools
    Syntax
    [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)]
    public class RequiresPlayModeAttribute : NUnitAttribute, IApplyToTest

    Constructors

    RequiresPlayModeAttribute(Boolean)

    Flags whether a test, test fixture, or assembly should run in PlayMode when run in the Editor.

    Declaration
    public RequiresPlayModeAttribute(bool requiresPlayMode = true)
    Parameters
    Type Name Description
    Boolean requiresPlayMode

    If true, the test is always run in PlayMode. If false, the test is always run in EditMode.

    Methods

    ApplyToTest(Test)

    Modifies a test as defined for the specific attribute.

    Declaration
    public void ApplyToTest(Test test)
    Parameters
    Type Name Description
    Test test

    The test to modify

    Back to top Copyright © 2022 Unity Technologies
    Generated by DocFX
    on Monday, November 14, 2022
    Terms of use