NUnit 2.6.6 Legacy Documentation. View NUnit 3 Documentation

TestCaseBuilders (NUnit 2.4)


TestCaseBuilders create Tests based on a MethodInfo. NUnit uses several TestCaseBuilders internally to create various kinds of TestMethods.

Extension Point

Addins use the host to access this extension point by name:
	IExtensionPoint testCaseBuilders = host.GetExtensionPoint( "TestCaseBuilders" );


The extension object passed to Install must implement either the ITestCaseBuilder or the ITestCaseBuilder2 interface:

	public interface ITestCaseBuilder
		bool CanBuildFrom( MethodInfo method );
		Test BuildFrom( MethodInfo method );

	public interface ITestCaseBuilder2 : ITestCaseBuilder
		bool CanBuildFrom( MethodInfo method, Test suite );
		Test BuildFrom( MethodInfo method, Test suite );

NUnit will call ITestCaseBuilder2 if it is available. Otherwise ITestCaseBuilder will be used.

The CanBuildFrom method should return true if the addin can build a test from the MethodInfo provided. Some TestCaseBuilder addins are only intended to apply to methods within a specific type of fixture. The suite argument of the ITestCaseBuilder2 interface may be used to make this determination.

The BuildFrom method should return a test constructed over the MethodInfo provided as an argument or null if the method cannot be used.