Class TestCaseAttribute
Marks a method as a parameterized test suite and provides arguments for each test case.
Inheritance
Inherited Members
Namespace: NUnit.Framework
Assembly: nunit.framework.dll
Syntax
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
public class TestCaseAttribute : NUnitAttribute, ITestBuilder, ITestCaseData, ITestData, IImplyFixture
Constructors
View SourceTestCaseAttribute(object?)
Construct a TestCaseAttribute with a single argument
Declaration
public TestCaseAttribute(object? arg)
Parameters
Type | Name | Description |
---|---|---|
object | arg |
TestCaseAttribute(object?, object?)
Construct a TestCaseAttribute with a two arguments
Declaration
public TestCaseAttribute(object? arg1, object? arg2)
Parameters
Type | Name | Description |
---|---|---|
object | arg1 | |
object | arg2 |
TestCaseAttribute(object?, object?, object?)
Construct a TestCaseAttribute with a three arguments
Declaration
public TestCaseAttribute(object? arg1, object? arg2, object? arg3)
Parameters
Type | Name | Description |
---|---|---|
object | arg1 | |
object | arg2 | |
object | arg3 |
TestCaseAttribute(params object?[]?)
Construct a TestCaseAttribute with a list of arguments. This constructor is not CLS-Compliant
Declaration
public TestCaseAttribute(params object?[]? arguments)
Parameters
Type | Name | Description |
---|---|---|
object[] | arguments |
Properties
View SourceArguments
Gets the list of arguments to a test case
Declaration
public object?[] Arguments { get; }
Property Value
Type | Description |
---|---|
object[] |
Author
The author of this test
Declaration
public string? Author { get; set; }
Property Value
Type | Description |
---|---|
string |
Category
Gets and sets the category for this test case. May be a comma-separated list of categories.
Declaration
public string? Category { get; set; }
Property Value
Type | Description |
---|---|
string |
Description
Gets or sets the description.
Declaration
public string? Description { get; set; }
Property Value
Type | Description |
---|---|
string | The description. |
ExcludePlatform
Comma-delimited list of platforms to not run the test for
Declaration
public string? ExcludePlatform { get; set; }
Property Value
Type | Description |
---|---|
string |
ExpectedResult
Gets or sets the expected result.
Declaration
public object? ExpectedResult { get; set; }
Property Value
Type | Description |
---|---|
object | The result. |
Explicit
Gets or sets a value indicating whether this TestCaseAttribute is explicit.
Declaration
public bool Explicit { get; set; }
Property Value
Type | Description |
---|---|
bool |
HasExpectedResult
Returns true if the expected result has been set
Declaration
public bool HasExpectedResult { get; }
Property Value
Type | Description |
---|---|
bool |
Ignore
Gets or sets the reason for ignoring the test
Declaration
public string? Ignore { get; set; }
Property Value
Type | Description |
---|---|
string |
IgnoreReason
Gets or sets the ignore reason. When set to a non-null non-empty value, the test is marked as ignored.
Declaration
public string? IgnoreReason { get; set; }
Property Value
Type | Description |
---|---|
string | The ignore reason. |
IncludePlatform
Comma-delimited list of platforms to run the test for
Declaration
public string? IncludePlatform { get; set; }
Property Value
Type | Description |
---|---|
string |
Properties
Gets the properties of the test case
Declaration
public IPropertyBag Properties { get; }
Property Value
Type | Description |
---|---|
IPropertyBag |
Reason
Gets or sets the reason for not running the test.
Declaration
public string? Reason { get; set; }
Property Value
Type | Description |
---|---|
string | The reason. |
RunState
Gets or sets the RunState of this test case.
Declaration
public RunState RunState { get; }
Property Value
Type | Description |
---|---|
RunState |
TestName
Gets or sets the name of the test.
Declaration
public string? TestName { get; set; }
Property Value
Type | Description |
---|---|
string | The name of the test. |
TestOf
The type that this test is testing
Declaration
public Type? TestOf { get; set; }
Property Value
Type | Description |
---|---|
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.
Declaration
public Type[]? TypeArgs { get; set; }
Property Value
Type | Description |
---|---|
Type[] |
Until
Gets and sets the ignore until date for this test case.
Declaration
public string? Until { get; set; }
Property Value
Type | Description |
---|---|
string |
Methods
View SourceBuildFrom(IMethodInfo, Test?)
Builds a single test from the specified method and context.
Declaration
public IEnumerable<TestMethod> BuildFrom(IMethodInfo method, Test? suite)
Parameters
Type | Name | Description |
---|---|---|
IMethodInfo | method | The MethodInfo for which tests are to be constructed. |
Test | suite | The suite to which the tests will be added. |
Returns
Type | Description |
---|---|
IEnumerable<TestMethod> |