Legacy Documentation. View NUnit 3 Documentation

Tips for Writing Extensions

An Extenders Guide will be published in the future. At the moment, writing an extension is a bit of an adventure. Extension authors are advised to join the nunit-developer list and post questions and comments there.

For the moment, the following tips may be of assistance.

  • The nunit.core.interfaces assembly is intended to be stable in the future while the nunit.core assembly will change from release to release. Right now, both assemblies are still in flux, but extensions that depend solely on the interfaces assembly will have a much better chance of surviving NUnit version changes. Unfortunately, this is rather difficult to do without duplicating a great deal of NUnit code. Most of the add-in samples provided with NUnit are currently version dependent.
  • If you place the definition of a custom attribute in the same assembly as your add-in, then user tests are dependent on the add-in assembly. If the add-in is version-dependent, then the user tests will also be version-dependent. We suggest placing any types referenced by user tests in a separate assembly, particularly if your extension relies on nunit.core.
  • If using Visual Studio, set Copy Local to false for any references to nunit.core or nunit.core.interfaces. This is especially important if you are also building NUnit itself.
  • There is currently no mechanism to allow decorators to apply in a particular order. NUnit applies decorators in the order in which they are returned through reflection, which may vary among different runtimes.
  • Avoid trying to "stretch" the existing extension points to do more than they were intended to do. Rather, let us know what further extension points you would like to see!