NUnit
   
   

Getting Started with NUnit
If you haven't already done so, go to our Download page, select a version of NUnit and download it. The Installation page contains instructions for installing on your system.

To get started using NUnit, read the Getting Started document. This article demonstrates the development process with NUnit in the context of a C# banking application. Check the Samples page for additional examples, including some in VB.Net, J# and managed C++.

Which Test Runner to use?
NUnit has two different ways to run your tests. The console runner, nunit-console.exe, is the fastest to launch, but is not interactive. The gui runner, nunit-gui.exe, is a Windows Forms application that allows you to work selectively with your tests and provides graphical feedback.

Console Runner
The nunit-console.exe program is a text-based runner and can be used when you want to run all your tests and don’t need a red/yellow/green indication of success or failure.

It is useful for automation of tests and integration into other systems. It automatically saves its results in XML format, allowing you to produce reports or otherwise process the results. The following is a screenshot of the console program.

In this example, nunit-console has just run the tests in the mock-assembly.dll that is part of the NUnit distribution. This assembly contains seven tests, three of which are not run. The first ignored test has an incorrect method signature, the second has been marked with the Ignore attribute and the third uses the Explicit attribute, so that it can only be run directly. Click here to see the XML produced for this test run.

Gui Runner
The nunit-gui.exe program is a graphical runner. It shows the tests in an explorer-like browser window and provides a visual indication of the success or failure of the tests. It allows you to selectively run single tests or suites and reloads automatically as you modify and re-compile your code. The following is a screenshot of nunit-gui running the same mock-assembly.dll shown in the previous example.

As you can see, the tests that were not run are marked with a yellow circle, while those that were run successfully are colored green. If any tests had failed, they would be marked red.



Copyright © 2002-2004 James W. Newkirk, Alexei A. Vorontsov, Charlie Poole. All Rights Reserved.