views:

85

answers:

1

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?

+4  A: 

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.

froh42
I was hoping there'd be an easier way. Well, thanks anyways, I'll mark yours as the answer.
Judah Himango
Easier? how much easier can it get? write the method once and put : BaseTestClass after the name of your test class...
SnOrfus