MbUnit & NAnt update

While trying to figure out why the recommend syntax for MbUnit in NAnt did'nt work I started working on my own NAnt task for MbUnit but figured it out in the end, what follows is a in depth guide to some internals, here goes.

Creating a NAnt task is very simple, a guide to creating a simple one can be found here. I built my task using VB.NET and ported the code over, watch for syntax and other errors in your code as NAnt will simply report that your taskk type cannot be loaded (even verbose mode), any indications on error reporting/catching in the NAnt API would be handy.

The ExecuteTask is a key method in a NAnt task and this gave me my starting point to inspect the MbUnit task source to see what was going on. A key type that the ExecuteTask method uses is the MbUnit type. This exposes several NAnt types one of which is the NAnt.Core.Types.FileSet which is exposed its self within the assemblies property. This is used to load assemblies into NAnt. The MbUnit type is exposed in a buildfile as a <test> attribute so this concludes me to reach the following.

    <includes asis="true" name="TestCode.dll" />

As reported to be correct syntax and generated by the MbUnit GUI but the syntax I suspect should read.

      <includes asis="true" name="TestCode.dll" />

You also need to copy the following MbUnit DLLs into the NAnt bin directory.

  • MbUnit.Core.dll
  • MbUnit.Framework.dll
  • MbUnit.Tasks.dll
  • Quickgraph.dll
  • QuickGraph.Algorithms.dll

This runs the tests (more progress than last night) but after the tests have been marked as complete the following happens.

System.NullReferenceException: Object reference not set to an instance of an obj
   at MbUnit.Core.Reports.ReportBase.GetFileName(ReportResult result, String out
putPath, String nameFormat, String extension) in C:\svnhome\trunk\MbUnit\MbUnit.
Core\Reports\ReportBase.cs:line 49

this was present in TestDriven.NET-1.0.855d.zip as taken from the automated build page. Tracing this back it seems that the result object is not being created, this is being returned from the quickgraph assemblies so after a successful pass should be ok. I going to continue to see how far I can get with creating my own light weight version of a NAnt task for MbUnit, this would help me debug whats going on. Thoughts welcome?


I saw a tip (can't find where I located it) that the NUnit2 task syntax will work with MbUnit so I altered such a build file, MbUnit raised an error as reported in this bug report (raised on the 11th November).  I just have to wait for the fix now or dig in some more and figure out why this might be occuring.


  • Hi Andrew,

    I'm currently addind tests for the NAnt task. I finished the tests for MSBuild yesterday and I hope to fix this damn to fix this damn NAnt task tonight.

    When I introduced assembly dependencies, this was a major refactoring and I did not have tests, so now the first step is takened, my tests are red. Just need the time to make them green again.

  • you should add report file attribute:

    hope that can help you

Comments have been disabled for this content.