Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Good Unit Testing Framework ?

I'm looking for a good unit testing framework for .NET
development. Any ideas ?

Liron Levy
Tuesday, October 01, 2002

Hi, I just saw CompuWare demonstrate theirs - looked real good - and of course there's the open source NUnit package.

Eugene Mortimore
Tuesday, October 01, 2002

A rundown I wrote recently for DEVELOPER CENTRAL:

- NUnit 2.0 is the second release of this open-source implementation of
the XUnit ideas. I just took a look at RC1, and it's looking pretty
good. Tests in NUnit are marked with the Test attribute, and can be
grouped into classes marked with the TestFixture attribute; all
discovery is dynamic at runtime, as it should be. There are both GUI and
command-line test consoles to run the tests. The command-line version
produces XML and lets you specify an XSLT file for formatting, giving
you excellent flexibility for presenting results.

NUnit also uses a variety of other attributes for flexibility. For
example, you can mark a test with the Ignore attribute to temporarily
suspend it, and use the Suite attribute to group tests into a hierarchy
(the GUI driver lets you select any point in the hierarchy to launch a
partial test run). The program will also build suites in a hierarchy
based on the namespace hierarchy for the test classes, so you don't need
to mark suites at all if you organize them correctly. NUnit is also
working on integration with the open-source NAnt build tool
(http://nant.sourceforge.net/index.html), about which I expect to write
more in the future.

.NETUnit is an LGPL'd implementation from Drew Marsh. Though it's at
version 0.9 at the moment, this one is still pretty immature: no
documentation to speak of, or anything installed to the Start menu. Grub
around in the installed code for a bit, and you'll find that a .NETUnit
test is a method identified with a special attribute. Test classes too
are marked by an attribute, rather than being required to derive from a
particular parent. Of note about .NETUnit is support for parameterized
tests so (with a proper test driver) you can feed multiple inputs into a
single test. The 0.9 version includes a console-based test driver
implementation, but there's no GUI for .NETUnit yet. This one appears to
have some advanced ideas, but you probably don't want to work with it
unless you're willing to roll up your sleeves and dig through the
supplied source code.

X-Unity 1.1, the only commercial entry in this set of programs, installs
a TestSuite class on your development computer. To build tests, you
inherit your own class from TestSuite, and then place methods (which
cannot have any parameters) marked with the TestCaseAttribute in the
class. The X-Unity test harness can execute any or all of these methods
as unit tests. Methods within TestSuite allow you to perform assertions,
which is how you know whether a test succeeded, as well as to send trace
messages to the X-Unity log.

X-Unity is particularly strong in integration. In addition to the GUI
client, it offers a command-line client with instructions for
integrating into the VS .NET Tools menu. There's also a batch build and
test utility that can rebuild your project from a VSS database, execute
tests, and label the VSS tree if the tests are passed. It will also send
e-mail automatically to keep you up to date on test progress. This level
of automation, along with the command-line control, makes X-Unity a
natural for complex build processes.

You can download an evaluation copy of X-Unity from the MIIK Web site.
It's fully functional, but limited to three tests. The real thing will
cost you $99 for a personal edition (without the automated utility) or
$139 for the professional edition. There's also team and enterprise
pricing (down to $19 per developer) that lets you choose how many
workstation and server licenses you need.

NUnit 2.0 RC1, free
http://sourceforge.net/projects/nunit

.NETUnity 0.9, free
http://sourceforge.net/projects/dotnetunit

X-Unity 1.1, starting at $99
MIIK Limited
Ukraine
+380 572 194 508
http://x-unity.miik.com.ua/

On the whole, I prefer the NUnit architecture and atrribute-driven
approach to everything. But if I were running a multi-developer project,
the integration features of X-Unity would be pretty attractive. .NETUnit
looks to be one to watch for the future.

Mike Gunderloy
Tuesday, October 01, 2002

NUnit is now up to RC3.  From what I understand, this has now been feature frozen and unless there are any further bugs found, this will be the next release.

Anil John
Tuesday, October 01, 2002

NUnit has now released version 2.0. It's really quite nice and has a ringing endorsement from Kent Beck himself, on their page http://nunit.org.

ns
Monday, October 07, 2002

What about HarnessIT by http://www.unitedbinary.com ?

Jason Watts
Tuesday, October 08, 2002

I've tried it and (IMHO) it is not a good testing framework.
The problem with the harnessIT product is that it does not allow you to run the tests from your own Main() method. Only as a DLL invoked from their test engine. This is important when you want to control ordering of loading
of DLLs etc. NUNIT allowed me to do this.

Liron Levy
Thursday, October 10, 2002

*  Recent Topics

*  Fog Creek Home