Legacy Documentation. View NUnit 3 Documentation

TestCaseProviders (NUnit 2.5)

Purpose

TestCaseProviders are used with parameterized tests to provide the specific test cases that will be used in calling the test.

Extension Point

Addins use the host to access this extension point by name:

	IExtensionPoint listeners = host.GetExtensionPoint( "ParameterProviders" );

Interface

The extension object passed to Install must implement the ITestCaseProvider interface:

	public interface ITestCaseProvider
	{
		bool HasTestCasesFor( MethodInfo method );
		IEnumerable GetTestCasesFor( MethodInfo method );
	}

HasTestCasesFor returns 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 should examine the provided MethodInfo 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:

  • Arguments
  • RunState
  • NotRunReason
  • ExpectedExceptionType
  • ExpectedExceptionName
  • ExpectedExceptionMessage
  • Result
  • Description
  • TestName

The ParameterSet class provides all these properties and may be used to avoid the overhead of reflecting on the properties.