NUnit – specifying a method to be called after every test

nunitunit testing

Does NUnit let me invoke a method after every test method?

e.g.

class SomeClass
{
   [SomeNUnitAttribute]
   public void CalledAfterEveryTest()
   {
   }
}

I'm aware of [SetUp] and [TearDown], but that only works for the tests in the current class. I want something like [TearDown], except it runs after every unit test, whether its in the current class or not. Possible?

Best Answer

The [TearDown] Attribute marks the cleanup method.

If you want it for multiple classes I believe you can add the teardown method to a base class and inherit from that in every test class that needs the teardown behaviour.