Table of Contents

Class TestCaseAttribute

Namespace
NUnit.Framework
Assembly
nunit.framework.dll

Marks a method as a parameterized test suite and provides arguments for each test case.

[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
public class TestCaseAttribute : NUnitAttribute, ITestBuilder, ITestCaseData, ITestData, IImplyFixture
Inheritance
TestCaseAttribute
Implements
Inherited Members

Constructors

TestCaseAttribute(object?)

Construct a TestCaseAttribute with a single argument

public TestCaseAttribute(object? arg)

Parameters

arg object

TestCaseAttribute(object?, object?)

Construct a TestCaseAttribute with a two arguments

public TestCaseAttribute(object? arg1, object? arg2)

Parameters

arg1 object
arg2 object

TestCaseAttribute(object?, object?, object?)

Construct a TestCaseAttribute with a three arguments

public TestCaseAttribute(object? arg1, object? arg2, object? arg3)

Parameters

arg1 object
arg2 object
arg3 object

TestCaseAttribute(params object?[]?)

Construct a TestCaseAttribute with a list of arguments. This constructor is not CLS-Compliant

public TestCaseAttribute(params object?[]? arguments)

Parameters

arguments object[]

Properties

Arguments

Gets the list of arguments to a test case

public object?[] Arguments { get; }

Property Value

object[]

Author

The author of this test

public string? Author { get; set; }

Property Value

string

Category

Gets and sets the category for this test case. May be a comma-separated list of categories.

public string? Category { get; set; }

Property Value

string

Description

Gets or sets the description.

public string? Description { get; set; }

Property Value

string

The description.

ExcludePlatform

Comma-delimited list of platforms to not run the test for

public string? ExcludePlatform { get; set; }

Property Value

string

ExpectedResult

Gets or sets the expected result.

public object? ExpectedResult { get; set; }

Property Value

object

The result.

Explicit

Gets or sets a value indicating whether this TestCaseAttribute is explicit.

public bool Explicit { get; set; }

Property Value

bool

true if explicit; otherwise, false.

HasExpectedResult

Returns true if the expected result has been set

public bool HasExpectedResult { get; }

Property Value

bool

Ignore

Gets or sets the reason for ignoring the test

public string? Ignore { get; set; }

Property Value

string

IgnoreReason

Gets or sets the ignore reason. When set to a non-null non-empty value, the test is marked as ignored.

public string? IgnoreReason { get; set; }

Property Value

string

The ignore reason.

IncludePlatform

Comma-delimited list of platforms to run the test for

public string? IncludePlatform { get; set; }

Property Value

string

Properties

Gets the properties of the test case

public IPropertyBag Properties { get; }

Property Value

IPropertyBag

Reason

Gets or sets the reason for not running the test.

public string? Reason { get; set; }

Property Value

string

The reason.

RunState

Gets or sets the RunState of this test case.

public RunState RunState { get; }

Property Value

RunState

TestName

Gets or sets the name of the test.

public string? TestName { get; set; }

Property Value

string

The name of the test.

TestOf

The type that this test is testing

public Type? TestOf { get; set; }

Property Value

Type

TypeArgs

Get or set the type arguments for a generic test method. If not set explicitly, the generic types will be inferred based on the test case parameters.

public Type[]? TypeArgs { get; set; }

Property Value

Type[]

Until

Gets and sets the ignore until date for this test case.

public string? Until { get; set; }

Property Value

string

Methods

BuildFrom(IMethodInfo, Test?)

Builds a single test from the specified method and context.

public IEnumerable<TestMethod> BuildFrom(IMethodInfo method, Test? suite)

Parameters

method IMethodInfo

The MethodInfo for which tests are to be constructed.

suite Test

The suite to which the tests will be added.

Returns

IEnumerable<TestMethod>