Version: Unity 6.2 (6000.2)
Language : English
Yield instructions for the Editor
Asynchronous tests

Parameterized tests

Unity Test Framework supports parameterized tests, which can be useful for data-driven testing.

Regular NUnit tests support both the [TestCase] and [ValueSource] attributes for parameterized tests. Unity tests only support ValueSource

The following example demonstrates use of ValueSource with a Unity test:

static int[] values = new int[] { 1, 5, 6 };

[UnityTest]
public IEnumerator MyTestWithMultipleValues([ValueSource("values")] int value)
{
    yield return null;
}

Ignore based on parameters

You can selectively ignore tests based on the parameters supplied to the test method by using the ParameterizedIgnoreAttribute.

Additional resources

Yield instructions for the Editor
Asynchronous tests
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961