TestFixtureTearDownAttribute (NUnit 2.1)
This attribute is used inside a TestFixture to provide a single set of functions that are performed once after all tests are completed. A TestFixture can have only one TestFixtureTearDown method. If more than one is defined the TestFixture will compile successfully but its tests will not run.
So long as any TestFixtureSetUp method runs without error, the TestFixtureTearDown method is guaranteed to run. It will not run if a TestFixtureSetUp method fails or throws an exception.
Example:
namespace NUnit.Tests { using System; using NUnit.Framework; [TestFixture] public class SuccessTests { [TestFixtureSetUp] public void Init() { /* ... */ } [TestFixtureTearDown] public void Cleanup() { /* ... */ } [Test] public void Add() { /* ... */ } } }
Inheritance
The TestFixtureTearDown attribute is inherited from any base class. Therefore, if a base class has defined a TestFixtureTearDown method, that method will be called after each test method in the derived class. If you wish to add more functionality in a derived class you need to mark the method with the appropriate attribute and then call the base class method.