Table of Contents

Class TestCaseSourceAttribute

Namespace
NUnit.Framework
Assembly
nunit.framework.dll

Indicates the source to be used to provide test fixture instances for a test class.

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

Constructors

TestCaseSourceAttribute(string)

Construct with the name of the method, property or field that will provide data

public TestCaseSourceAttribute(string sourceName)

Parameters

sourceName string

The name of a static method, property or field that will provide data.

TestCaseSourceAttribute(string, object?[]?)

Construct with a name

public TestCaseSourceAttribute(string sourceName, object?[]? methodParams)

Parameters

sourceName string

The name of a static method, property or field that will provide data.

methodParams object[]

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

public TestCaseSourceAttribute(Type sourceType)

Parameters

sourceType Type

The type that will provide data

TestCaseSourceAttribute(Type, string)

Construct with a Type and name

public TestCaseSourceAttribute(Type sourceType, string sourceName)

Parameters

sourceType Type

The Type that will provide data

sourceName string

The name of a static method, property or field that will provide data.

TestCaseSourceAttribute(Type, string, object?[]?)

Construct with a Type and name

public TestCaseSourceAttribute(Type sourceType, string sourceName, object?[]? methodParams)

Parameters

sourceType Type

The Type that will provide data

sourceName string

The name of a static method, property or field that will provide data.

methodParams object[]

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

Category

Gets or sets the category associated with every fixture created from this attribute. May be a single category or a comma-separated list.

public string? Category { get; set; }

Property Value

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.

public object?[]? MethodParams { get; }

Property Value

object[]

SourceName

The name of a the method, property or field to be used as a source

public string? SourceName { get; }

Property Value

string

SourceType

A Type to be used as a source

public Type? SourceType { get; }

Property Value

Type

Methods

BuildFrom(IMethodInfo, Test?)

Builds any number of tests from the specified method and context.

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

Parameters

method IMethodInfo

The IMethod for which tests are to be constructed.

suite Test

The suite to which the tests will be added.

Returns

IEnumerable<TestMethod>