Making unit tests for .NET framework in Visual Studio 2008

Finding a tool for automated unit tests that works with the .NET Framework. The backend classes are written in C# and the IDE i am using is Microsoft Visual Studio 2008.
1 answer

NUnit for unit-testing

NUnit is an unit testing framework for the .Net framework and is based on JUnit.

Minimal setup:

For making a test case, a normal c# class is created, which imports the NUnit framework.

using NUnit.Framework

The class must have the attribute [TextFixture] to indicate, that this class has test code.
The attributes [SetUp] and [TearDown] are optional and can be used if some pre/post conditions are need for each test (e.g. resetting the DB).

The different test cases are marked by the attribute [Test]. Different static methods of the Assert class are used for checking the results.


public class MyTests
public void setup()
//fill database with test data

public void tearDown()
//delete data in database

public void test1()
user = ... //search for user by id