diff --git a/README.md b/README.md index 985f16c..5a18aef 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,40 @@ public class MyTestClass ``` +#### UnityVersion + +`UnityVersionAttribute` is an NUnit test attribute class to skip test run if Unity version is older and/or newer than specified. + +This attribute can attached to test method, test class (`TestFixture`) and test assembly. +Can be used with sync Test, async Test, and UnityTest. + +Usage: + +```csharp +using System; +using NUnit.Framework; +using TestHelper.Attributes; + +[TestFixture] +public class MyTestClass +{ + [Test] + [UnityVersion(newerThanOrEqual: "2022")] + public void MyTestMethod() + { + // Test run only for Unity 2022.1.0f1 or later. + } + + [Test] + [UnityVersion(olderThan: "2019.4.0f1")] + public void MyTestMethod() + { + // Test run only for Unity older than 2019.4.0f1. + } +} +``` + + #### CreateScene `CreateSceneAttribute` is an NUnit test attribute class to create new scene before running test. diff --git a/Runtime/Attributes/UnityVersionAttribute.cs b/Runtime/Attributes/UnityVersionAttribute.cs index 9e7f9e4..5b9a50b 100644 --- a/Runtime/Attributes/UnityVersionAttribute.cs +++ b/Runtime/Attributes/UnityVersionAttribute.cs @@ -20,6 +20,7 @@ public class UnityVersionAttribute : NUnitAttribute, IApplyToTest /// /// Skip this test run if Unity version is older and/or newer than specified. + /// Valid format, e.g., "2023.2.16f1", "2023.2", and "2023". /// /// This test will run if the Unity editor version is newer than or equal the specified version. /// This test will run if the Unity editor version is older than the specified version.