TestCaseProviders are used with parameterized tests to provide the specific test cases that will be used in calling the test.
Addins use the host to access this extension point by name:
IExtensionPoint listeners = host.GetExtensionPoint( "TestCaseProviders" );
The extension object passed to Install must implement either the ITestCaseProvider or the ITestCaseProvider2 interface:
public interface ITestCaseProvider { bool HasTestCasesFor( MethodInfo method ); IEnumerable GetTestCasesFor( MethodInfo method ); } public interface ITestCaseProvider2 : ITestCaseProvider { bool HasTestCasesFor( MethodInfo method, Test suite ); IEnumerable GetTestCasesFor( MethodInfo method, Test suite ); }
NUnit will call ITestCaseProvider2 if it is available. Otherwise ITestCaseProvider will be used.
HasTestCasesFor should return true if the provider is able to supply test cases for the specified method. If a provider only wants to be used on certain types of tests, it can examine the provided MethodInfo and the suite for which the test is being constructed and return true or false based on what it finds.
The GetParametersFor method should return a list of individual test cases. Each test case may be expressed as a ParameterSet, as an array of arguments or as a custom object containing one or more of the following properties:
The ParameterSet class provides all these properties and may be used to avoid the overhead of reflecting on the properties.