Unit Test Setup and Tear Down

A good practice for your unit tests is to write them for a known state of the system; this includes the database, files, and anything that makes up the entire system. This ensures that developers can rely on these items being there when they write their tests. Of course the tests themselves often disrupt this state. You might have a test that deletes data, changes it, adds new records, and the like. In this case, you need to be able to re-initialize the state of the system prior to executing your tests (and/or after executing your tests). to ensure both a steady state to test against and a one-click test run experience for developers (another good practice for unit testing).

You typically need to write code to keep ...

Get Microsoft® Visual Studio® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.