docs.unity.cn
    Show / Hide Table of Contents

    Class UnityTearDownAttribute

    The UnitySetUpAttribute and UnityTearDown attributes are identical to the standard SetUp and TearDown attributes, with the exception that they allow for IEditModeTestYieldInstruction. The UnitySetUp and UnityTearDown attributes expect a return type of IEnumerator.

    public class SetUpTearDownExample
    {
        [UnitySetUp]
        public IEnumerator SetUp()
        {
            yield return new EnterPlayMode();
        }
    
        [Test]
        public void MyTest()
        {
            Debug.Log("This runs inside playmode");
        }
    
        [UnityTearDown]
        public IEnumerator TearDown()
        {
            yield return new ExitPlayMode();
        }
    }

    Inheritance
    Object
    UnityTearDownAttribute
    Namespace: UnityEngine.TestTools
    Syntax
    [AttributeUsage(AttributeTargets.Method)]
    public class UnityTearDownAttribute : NUnitAttribute
    Back to top Copyright © 2023 Unity Technologies — Terms of use
    Generated by DocFX
    on Monday, July 10, 2023