• Feeds

    Subscribe in a reader

  • Ads

NUnit 2.1 Beta 1

Beta 1 of NUnit 2.1 is not available from http://nunit.sf.net.

There's a lot new in this release, and most of it is very good. I've grown to becomequite dependent on NUnit in recent months, and I really like a lot of the changesthat have been made.

Pros:

  • Test Projects. NUnit 2.1 makes is much easier to run sets of testthat are implemented across multiple assemblies. This makes NUnit a lot more viablein large-scale projects, where there might be a unit test assembly for each logicallayer of the application. NUnit 2.1 allows you to load all of those assemblies inone fell swoop and exectute the tests as if they were all in a single assembly. Thismakes it a lot easier to aggregate test run results, since the tool does it all foryou. I think this is the killer feature for NUnit 2.1 (if only because I helpedbuild a custom front end to NUnit 2.0 to do the exact same thing!)
  • Per-assembly configuration files. NUnit 2.1 allows you to specifya .config for each test assembly. Granted, this feature was technically availablein NUnit 2.0 (all you had to do was name the fille <myAssemblyName>.dll.config)but it wasn't documented anywhere. Now, the GUI has a property page that lets youspecify and config file you want.
  • New Assertions. 2.1 implements that following assertions that youcan use in your tests:
    • IsTrue()
    • IsFalse()
    • IsNull()
    • IsNotNull()
    • AreSame
    • AreEqual
    • Fail()
    Not really a huge change, but the assertion model is now a little bit more explicit,and I'm never one to complain about syntactic sugar.
  • Fixture-level set up and tear down. NUnit 2.0 had per-test [SetUp]and [TearDown] attributes. These methods were guaranteed to be run respectively beforeand after each individual test. Thus helped keep state from bleeding across tests,but sometimes caused undue redundancy as some implementations could actually be OKonly initializing state once before any test was exectuted. The new [TestFixtureSetUp]and [TestFixtureTearDown] attributes are built for exactly this sort of thing.

All that being said, there are a couple things that I wish weren't true about thenew version.

Cons:

  • Upgrade from 2.0 requires recompilation. This is ostensibly due tobreaking changes inside of nunit.framework.dll. Understandable, but it would be niceif 2.1 was backward-compatible with 2.0 out of the box.
  • Deprecated Assertion class. All that new assertion functionalitymentioned above is implemented through a new Assert class. The old Assertion classhas been marked as [Obsolete]. It will still work, but it means that you'll get abunch of compiler warnings when you build against 2.1. This is extremely frustratingand prohibitive in large projects where there might be 1000's of assertions.

One thing that I'd like to see is the ability is an extensible result processingarchitecture. NUnit generates XML test results and even allows you to runthem though arbitrary XSLT, but I'd like to see a plug-in architecture so I can providemy own result processor. Specifically, I'd like the ability to store resultsin a database correlated by build number so I track the results of my unittest execution over time. The ability to provide a custom XSLT stylesheetis nice, but a fully customizable plug-in would be nicer :)