Class TestFixtureSourceAttribute
Identifies the source used to provide test fixture instances for a test class.
Inherited Members
Namespace: NUnit.Framework
Assembly: nunit.framework.dll
Syntax
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
public class TestFixtureSourceAttribute : NUnitAttribute, IFixtureBuilder2, IFixtureBuilder
Constructors
View SourceTestFixtureSourceAttribute(string)
Construct with the name of the method, property or field that will provide data
Declaration
public TestFixtureSourceAttribute(string sourceName)
Parameters
Type | Name | Description |
---|---|---|
string | sourceName | The name of a static method, property or field that will provide data. |
TestFixtureSourceAttribute(Type)
Construct with a Type
Declaration
public TestFixtureSourceAttribute(Type sourceType)
Parameters
Type | Name | Description |
---|---|---|
Type | sourceType | The type that will provide data |
TestFixtureSourceAttribute(Type, string)
Construct with a Type and name
Declaration
public TestFixtureSourceAttribute(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. |
Fields
View SourceMUST_BE_STATIC
Error message string is public so the tests can use it
Declaration
public const string MUST_BE_STATIC = "The sourceName specified on a TestCaseSourceAttribute must refer to a static field, property or method."
Field Value
Type | Description |
---|---|
string |
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 |
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(ITypeInfo)
Builds any number of test fixtures from the specified type.
Declaration
public IEnumerable<TestSuite> BuildFrom(ITypeInfo typeInfo)
Parameters
Type | Name | Description |
---|---|---|
ITypeInfo | typeInfo | The TypeInfo for which fixtures are to be constructed. |
Returns
Type | Description |
---|---|
IEnumerable<TestSuite> |
BuildFrom(ITypeInfo, IPreFilter)
Builds any number of test fixtures from the specified type.
Declaration
public IEnumerable<TestSuite> BuildFrom(ITypeInfo typeInfo, IPreFilter filter)
Parameters
Type | Name | Description |
---|---|---|
ITypeInfo | typeInfo | The TypeInfo for which fixtures are to be constructed. |
IPreFilter | filter | PreFilter used to select methods as tests. |
Returns
Type | Description |
---|---|
IEnumerable<TestSuite> |
GetParametersFor(Type)
Returns a set of ITestFixtureData items for use as arguments to a parameterized test fixture.
Declaration
public IEnumerable<ITestFixtureData> GetParametersFor(Type sourceType)
Parameters
Type | Name | Description |
---|---|---|
Type | sourceType | The type for which data is needed. |
Returns
Type | Description |
---|---|
IEnumerable<ITestFixtureData> |