docs.unity.cn
    Show / Hide Table of Contents

    Class ParameterizedIgnoreAttribute

    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
    ParameterizedIgnoreAttribute
    Namespace: UnityEngine.TestTools
    Syntax
    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
    public class ParameterizedIgnoreAttribute : NUnitAttribute, IWrapTestMethod
    Examples

    The following example shows a method to use the ParameterizedIgnore 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(nameof(MyTestCaseSource))]
       [ParameterizedIgnore("b", 3)]
       public void Test(string someString, int someInt)
       {
           Assert.Pass();
       }
    }

    It could also be used together with the Values attribute in NUnit:

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

    Constructors

    ParameterizedIgnoreAttribute(Object[])

    Declaration
    public ParameterizedIgnoreAttribute(params object[] Arguments)
    Parameters
    Type Name Description
    Object[] Arguments

    Properties

    Arguments

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

    Reason

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

    Methods

    Wrap(TestCommand)

    Declaration
    public TestCommand Wrap(TestCommand command)
    Parameters
    Type Name Description
    TestCommand command
    Returns
    Type Description
    TestCommand
    Back to top Copyright © 2022 Unity Technologies
    Generated by DocFX
    on Monday, November 14, 2022
    Terms of use