Nunit Framework

A port of Kent Beck and Erich Gamma's JUnit TestingFramework for all languages on the .Net platform.

Currently at version 2.0. Versions 1.x were straight ports of JUnit. Version 2.0 has diverged a bit from JUnit and uses more .NET-specific idioms. For example, it takes advantage of custom attributes to avoid the need for inheritance from a common TestCase class.

Nov 2003 - New version available 2.1.4, lots of new features.

VB, VisualJaySharpDotNet, Managed C++ and C# examples are provided.

There is also an NUnitAddin for VisualStudioDotNet. It runs NUnit tests directly in the IDE:

See also TestDrivenDotNet, a supporting VisualStudio plugin.

I think the old name of this page sucked, so I renamed it (and updated all links).

BTW I think NUnit is one of the better XUnits, especially the use of MetaData attributes instead of inheritance - unit testing should be a type of AspectOrientedProgramming, not part of your inheritance hierarchy.

-- StephenGryphon

I'm getting very hooked on Nunit. The whole concept of unit testing is very satisfying. I'm getting addicted to the GreenBar. I have a couple of questions I'm hoping fellow Nunit Testers could help me with.

What is the best way to organize assemblies? Do you include your test cases in the production code or in separate assemblies? How do you combine each assembly's test code into a single integration test?

-- KrisWenzel

I am certain there are a number of ways to organize assemblies. The method I prefer is to create a separate Test assembly in my project/solution file. This way I can run my tests after each build by setting up the Nunit executable to run after the build is complete. In order for all tests from differing assemblies to run, create a Test Suite that combines all the Test Fixtures and run that. Also, for a release I can remove the assembly when shipping (if necessary).

-- PaulFriedman

That sounds like what I wanted to do, but I am a bit confused. If your tests reside in a separate assembly, how can they refer to (and thus test) classes in an exe assembly in the solution?

One easy solution is to put all your code into DLL assemblies, and let your EXE consist of only a simple Main() method.

Found a good tutorial on Test-driven Development using NUnit at (BrokenLink)

-- JoeBeck

See XunitDotNet, a possible NUnit replacement.
See also NunitAsp, NunitWeb, DotNetUnit, CsUnit, NcfUnit, NunitForms
CategoryDotNet CategoryTesting: TestingFramework for RegressionTesting of (MicrosoftDotNet)components and programs.

View edit of August 8, 2009 or FindPage with title or text search