NUnit 2.6.6 Legacy Documentation. View NUnit 3 Documentation

TestDecorators (NUnit 2.4)

Purpose

TestDecorators are able to modify a test after it has been constructed.

Extension Point

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

	IExtensionPoint testDecorators = host.GetExtensionPoint( "TestDecorators" );

Interface

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

	public interface ITestDecorator
	{
		Test Decorate( Test test, MemberInfo member );
	}

The Decorate method may do several things, depending on what it needs to accomplish:

  1. Return test unmodified
  2. Modify properties of the test object and return it
  3. Replace test with another object, either discarding the original or aggregating it in the new test.

Depending on what the decorator does, it may need to run ahead of other decorators or after them. Decorators should be installed using the Install method overload that takes a priority. The priorities range from 1 to 9 and decorators with lower priority values are installed first. The following standard values are defined for use if desired: