docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class UnityPlatformAttribute

    Use this attribute to define a specific set of platforms you want or do not want your test(s) to run on.

    You can use this attribute on the test method, test class, or test assembly level. Use the supported RuntimePlatform enumeration values to specify the platforms. You can also specify which platforms to test by passing one or more RuntimePlatform values along with or without the include or exclude properties as parameters to the Platform attribute constructor.

    The test(s) skips if the current target platform is:

    • Not explicitly specified in the included platforms list
    • In the excluded platforms list
    Inheritance
    object
    Attribute
    NUnitAttribute
    UnityPlatformAttribute
    Implements
    IApplyToTest
    Inherited Members
    Attribute.Equals(object)
    Attribute.GetCustomAttribute(Assembly, Type)
    Attribute.GetCustomAttribute(Assembly, Type, bool)
    Attribute.GetCustomAttribute(MemberInfo, Type)
    Attribute.GetCustomAttribute(MemberInfo, Type, bool)
    Attribute.GetCustomAttribute(Module, Type)
    Attribute.GetCustomAttribute(Module, Type, bool)
    Attribute.GetCustomAttribute(ParameterInfo, Type)
    Attribute.GetCustomAttribute(ParameterInfo, Type, bool)
    Attribute.GetCustomAttributes(Assembly)
    Attribute.GetCustomAttributes(Assembly, bool)
    Attribute.GetCustomAttributes(Assembly, Type)
    Attribute.GetCustomAttributes(Assembly, Type, bool)
    Attribute.GetCustomAttributes(MemberInfo)
    Attribute.GetCustomAttributes(MemberInfo, bool)
    Attribute.GetCustomAttributes(MemberInfo, Type)
    Attribute.GetCustomAttributes(MemberInfo, Type, bool)
    Attribute.GetCustomAttributes(Module)
    Attribute.GetCustomAttributes(Module, bool)
    Attribute.GetCustomAttributes(Module, Type)
    Attribute.GetCustomAttributes(Module, Type, bool)
    Attribute.GetCustomAttributes(ParameterInfo)
    Attribute.GetCustomAttributes(ParameterInfo, bool)
    Attribute.GetCustomAttributes(ParameterInfo, Type)
    Attribute.GetCustomAttributes(ParameterInfo, Type, bool)
    Attribute.GetHashCode()
    Attribute.IsDefaultAttribute()
    Attribute.IsDefined(Assembly, Type)
    Attribute.IsDefined(Assembly, Type, bool)
    Attribute.IsDefined(MemberInfo, Type)
    Attribute.IsDefined(MemberInfo, Type, bool)
    Attribute.IsDefined(Module, Type)
    Attribute.IsDefined(Module, Type, bool)
    Attribute.IsDefined(ParameterInfo, Type)
    Attribute.IsDefined(ParameterInfo, Type, bool)
    Attribute.Match(object)
    Attribute.TypeId
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.TestTools
    Assembly: UnityEngine.TestRunner.dll
    Syntax
    [AttributeUsage(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Method, AllowMultiple = true)]
    public class UnityPlatformAttribute : NUnitAttribute, IApplyToTest
    Examples
    using UnityEngine;
    using UnityEngine.TestTools;
    using NUnit.Framework;
    
    [TestFixture]
    public class TestClass
    {
        [Test]
        [UnityPlatform(RuntimePlatform.WindowsPlayer)]
        public void TestMethod()
        {
            Assert.AreEqual(Application.platform, RuntimePlatform.WindowsPlayer);
        }
    }

    Constructors

    UnityPlatformAttribute()

    Constructs a new instance of the UnityPlatformAttribute class.

    Declaration
    public UnityPlatformAttribute()

    UnityPlatformAttribute(params RuntimePlatform[])

    Constructs a new instance of the UnityPlatformAttribute class with a list of platforms to include.

    Declaration
    public UnityPlatformAttribute(params RuntimePlatform[] include)
    Parameters
    Type Name Description
    RuntimePlatform[] include

    The different RuntimePlatform to run the test on.

    Properties

    exclude

    List the platforms you do not want to have your tests run on.

    Declaration
    public RuntimePlatform[] exclude { get; set; }
    Property Value
    Type Description
    RuntimePlatform[]

    include

    A subset of platforms you need to have your tests run on.

    Declaration
    public RuntimePlatform[] include { get; set; }
    Property Value
    Type Description
    RuntimePlatform[]

    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

    Implements

    NUnit.Framework.Interfaces.IApplyToTest
    In This Article
    Back to top
    Copyright © 2024 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)