Class TestCaseSourceAttribute
Indicates the source to be used to provide test fixture instances for a test class.
Inherited Members
Namespace: NUnit.Framework
Assembly: nunit.framework.dll
Syntax
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
public class TestCaseSourceAttribute : NUnitAttribute, ITestBuilder, IImplyFixture
Constructors
View SourceTestCaseSourceAttribute(string)
Construct with the name of the method, property or field that will provide data
Declaration
public TestCaseSourceAttribute(string sourceName)
Parameters
Type | Name | Description |
---|---|---|
string | sourceName | The name of a static method, property or field that will provide data. |
TestCaseSourceAttribute(string, object?[]?)
Construct with a name
Declaration
public TestCaseSourceAttribute(string sourceName, object?[]? methodParams)
Parameters
Type | Name | Description |
---|---|---|
string | sourceName | The name of a static method, property or field that will provide data. |
object[] | methodParams | A set of parameters passed to the method, works only if the Source Name is a method. If the source name is a field or property has no effect. |
TestCaseSourceAttribute(Type)
Construct with a Type
Declaration
public TestCaseSourceAttribute(Type sourceType)
Parameters
Type | Name | Description |
---|---|---|
Type | sourceType | The type that will provide data |
TestCaseSourceAttribute(Type, string)
Construct with a Type and name
Declaration
public TestCaseSourceAttribute(Type sourceType, string sourceName)
Parameters
Type | Name | Description |
---|---|---|
Type | sourceType | The Type that will provide data |
string | sourceName | The name of a static method, property or field that will provide data. |
TestCaseSourceAttribute(Type, string, object?[]?)
Construct with a Type and name
Declaration
public TestCaseSourceAttribute(Type sourceType, string sourceName, object?[]? methodParams)
Parameters
Type | Name | Description |
---|---|---|
Type | sourceType | The Type that will provide data |
string | sourceName | The name of a static method, property or field that will provide data. |
object[] | methodParams | A set of parameters passed to the method, works only if the Source Name is a method. If the source name is a field or property has no effect. |
Properties
View SourceCategory
Gets or sets the category associated with every fixture created from this attribute. May be a single category or a comma-separated list.
Declaration
public string? Category { get; set; }
Property Value
Type | Description |
---|---|
string |
MethodParams
A set of parameters passed to the method, works only if the Source Name is a method. If the source name is a field or property has no effect.
Declaration
public object?[]? MethodParams { get; }
Property Value
Type | Description |
---|---|
object[] |
SourceName
The name of a the method, property or field to be used as a source
Declaration
public string? SourceName { get; }
Property Value
Type | Description |
---|---|
string |
SourceType
A Type to be used as a source
Declaration
public Type? SourceType { get; }
Property Value
Type | Description |
---|---|
Type |
Methods
View SourceBuildFrom(IMethodInfo, Test?)
Builds any number of tests from the specified method and context.
Declaration
public IEnumerable<TestMethod> BuildFrom(IMethodInfo method, Test? suite)
Parameters
Type | Name | Description |
---|---|---|
IMethodInfo | method | The IMethod for which tests are to be constructed. |
Test | suite | The suite to which the tests will be added. |
Returns
Type | Description |
---|---|
IEnumerable<TestMethod> |