August, 2007

Tuesday, August 7th, 2007

NUnit Extras: Test Result Summarizer

NUnit is currently built under five different runtimes on Windows – plus two on Linux. Each build is tested under the same runtime on which it was built and on a number of the other runtimes. That’s a lot of TestResult files.

I use nunit-summary.exe to quickly view what happened in a particular run. For example,

nunit-summary TestResult-mono-1.0.xml -noheader -brief

gives me a simple, one-line summary of what happened when I ran my tests under mono-1.0 – the naming convention is built into my build script. The following command gives me a set of files TestResult-net-1.0.txt, TestResult-net-1.1.txt, etc. each containing the summary line as well as any failed or not run tests for the corresponding xml file.

nunit-summary TestResult*.xml -out=*.txt

See the help for the command for other things you can do, including using your own xsl to transform the output.

The nunit-summary program is available on the GitHub.

Tuesday, August 7th, 2007

Speed Up Reloading in NUnit 2.4.2

When running under .NET 2.0, NUnit is rather slow at loading tests these days. Although many folks only noticed the slowdown with the release of NUnit 2.4, loading a large set of tests with NUnit 2.2 also takes more time – about twice as much – under .NET 2.0 as .NET 1.1.

There doesn’t appear to be any easy solution to this problem. Inefficiencies in the Reflection mechanism and/or how we are using it seem to be the root of it and NUnit has been making more and more use of Reflection as new options, attributes and add-in capabilities have come along.

However, with NUnit 2.4.2, there is a simple workaround that may reduce the pain!

Try these steps:

  1. Load your test assembly or NUnit project as usual with the NUnit Gui.
  2. Identify a branch of the tree in which you will be working for the next 30 to 60 minutes. This can be either a TestFixture or a namespace that includes multiple fixtures.
  3. Right-click on the tree node you selected and select Load Fixture from the context menu. NUnit will reload only the selected tree branch.
  4. As you modify your assemblies and reload the tests, NUnit will continue to reload only the tree branch you selected. This can be a substantial time savings. If you wish to select a smaller subset of the tests, you can repeat the above steps. If you need to go back to the full set of tests, right-click in the tree and select Clear Fixture.

At this time, the fixture setting is not remembered between NUnit sessions, so this speed-up is only available to those who keep the Gui running while they work. This is actually how the NUnit Gui is designed to be used.

I’ll be working on speeding up test loading in the long-term, but in the meantime I hope this workaround helps.

Monday, August 6th, 2007

NUnit 2.4.2 Release

NUnit 2.4.2 is out and available here. It includes additions to the new constraint-based Assert syntax and new attributes to facilitate testing under various culture settings. The gui has been enhanced to save the visual state of the tree, including the currently selected test, and to allow loading just the fixture you are working on, which saves a great deal of time on reloads.

For a full description of features, read the release notes..