Often you will find yourself reusing a lot of code when writing related test cases and, to prevent code duplication, the SetUp and TearDown attributes can be used to perform any initialisation and clean-up code required by multiple methods within the test class. For instance, you would use SetUp to create database connections or default data values required to test a group of methods belonging to the same class. The TearDown attribute is then used to close and dispose of any objects created by the SetUp method.
While it is important to ensure that your application does what it is supposed to when it has all the right information, it can be just as important to make sure it handles things when the data is bad. NUnit caters for unit tests to monitor exception handling through the ExpectedException attribute. Hence by telling NUnit that a certain type of exception is expected to be thrown in a particular situation, it is possible to build test cases for when things go wrong.
Last but not least, the Ignore attribute can be used to tell NUnit to skip over a particular test method. This is a shortcut for removing or commenting test code without losing it altogether. Ignored test cases will still appear in your NUnit results, but will be represented with a yellow light rather than the red (failed) or green (passed) icons. Ignore is particularly useful if you are interrupted while coding test methods and need to return later to complete them.