I'm working on a variation of this stack overflow answer that provides reliable cleanup of tests. How do you write unit tests for NUnit addins?
Examining how NUnit self tests, I have determined:
- You can write tests, that pass, that verify correct behavior of NUnit for failing tests.
- You write unit tests against test fixtures in a separate assembly (otherwise the fixtures under test will execute with your unit tests)
- Use NUnit.TestUtilities.TestBuilder to create fixtures and call TestSuite.Run method.
What I don't see are any tests of the add-in process. I've got errors occurring sometime between install and execution. How would I unit test implementations the following?
- IAddin.Install
- ITestDecorator.Decorate
Here's an article by someone who hacked a way to do it: manipulating some of the singletons in the NUnit add-in implementation to swap his add-in in and out.
http://www.bryancook.net/2009/09/testing-nunit-addins-from-within-nunit.html