docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ParametrizedIgnoreAttribute

    This attribute is an alternative to the standard Ignore attribute in NUnit. It allows for ignoring tests based on arguments which were passed to the test method.

    Inheritance
    object
    Attribute
    NUnitAttribute
    ParametrizedIgnoreAttribute
    Implements
    IWrapTestMethod
    ICommandWrapper
    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.Method, AllowMultiple = true, Inherited = true)]
    public class ParametrizedIgnoreAttribute : NUnitAttribute, IWrapTestMethod, ICommandWrapper
    Examples

    The following example shows a method to use the `ParametrizedIgnore` attribute to ignore only one test with specific combination of arguments, where someString is `b` and someInt is `10`.

    using NUnit.Framework;
         using System.Collections.Generic;
         using UnityEngine.TestTools;
    
     public class MyTestsClass
     {
         public static IEnumerable<TestCaseData> MyTestCaseSource()
         {
             for (int i = 0; i < 5; i++)
             {
                 yield return new TestCaseData("a", i);
                 yield return new TestCaseData("b", i);
             }
         }
    
         [Test, TestCaseSource("MyTestCaseSource")]
         [ParametrizedIgnore("b", 3)]
         public void Test(string someString, int someInt)
         {
             Assert.Pass();
         }
     }</code></pre>
    

    It could also be used together with `Values` attribute in [NUnit](http://www.nunit.org/).

    using NUnit.Framework;
         using UnityEngine.TestTools;
    
     public class MyTestsClass
     {
         [Test]
         [ParametrizedIgnore("b", 10)]
         public void Test(
             [Values("a", "b")] string someString,
             [Values(5, 10)] int someInt)
         {
             Assert.Pass();
         }
     }</code></pre>
    

    Constructors

    ParametrizedIgnoreAttribute(params object[])

    Initializes a new instance of the ParametrizedIgnoreAttribute class with a argument combination that is ignored.

    Declaration
    public ParametrizedIgnoreAttribute(params object[] arguments)
    Parameters
    Type Name Description
    object[] arguments

    The argument combination to ignore

    Properties

    Arguments

    Argument combination for the test case to ignore.

    Declaration
    public object[] Arguments { get; }
    Property Value
    Type Description
    object[]

    Reason

    Reason for the ignore.

    Declaration
    public string Reason { get; set; }
    Property Value
    Type Description
    string

    Methods

    Wrap(TestCommand)

    Wraps a test command with the command to handled parametrized ignore.

    Declaration
    public TestCommand Wrap(TestCommand command)
    Parameters
    Type Name Description
    TestCommand command

    The command to wrap.

    Returns
    Type Description
    TestCommand

    A command handling parametrized ignore, with respect to the inner command.

    Implements

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