CI Factory with NUnit (rather than MbUnit)

I decided to add some unit tests into my first CI Factory project.  First I used a reference to MbUnit.Framework.dll in my test project, this is the unit test framework which ships with CI Factory, and all worked fine. 

No disrespect to MbUnit, but I decided I really wanted to use NUnit so I can utilise the larger amount of documentation and community knowledge that exists for NUnit (even though it might not be as flexible as MbUnit).  So I added NUnit 2.2.8 (.NET 2.0 version) underneath my CI Factory Third Party folder and flipped the test project over to use NUnit with a reference to NUnit.Framework.dll instead of MbUnit.Framework.dll.

Cruise Control blew up with an error in the NAnt Output log;

External Program Failed: C:\Program Files\NCover\NCover.Console.exe (return code was 1)

Oops!!  I know the issue is within the file Build/Packages/NCover/NCover.Target.xml, probably leading to Build/Packages/DotNetUnitTest/UnitTest.Target.xml but I couldn't find anything obvious to edit.

In the end the Solution was horribly simple and I let out a loud DOH!.  I just left the reference to MbUnit.Framework.dll in my test project, in addition to the NUnit.Framework.dll reference which actually performs the unit tests.

I can now run the NUnit GUI to run my tests on my development machine.  If they pass, I check in, Cruise Control builds the project and happily runs my unit tests in automated mode.

Happy, happy, joy, joy

P.S. I did muse that it could be the lack of an NUnit.Tasks.dll for NAnt to hook into which might be the issue, but I'm no expert so this is a bit of a wild stab in the dark.

Technorati tags: ,

Print | posted on Monday, April 16, 2007 12:24 AM

Comments on this post

# re: CI Factory with NUnit (rather than MbUnit)

Requesting Gravatar...
Hi Liam,

I am lead on the MbUnit project so I am always interested in learning about why folks don't adopt MbUnit.

You can use MbUnit in the same way as NUnit, unless you wish to use the new assert syntax in NUnit 2.5 then MbUnit 2.4 and NUNit 2.4 can be used the same. The same asserts and fixtures etc.

MbUnit does have a far greater degree of testing ability so you can then make the switch to those features from an NUnit style as you wish.

MbUnit's community is growing each day, with active mailing lists and blogs for you to learn from and ask questions of. I agree the documentation needs work and this is on going but to unit test to the same degree as NUnit you don't need to learn anything new.

Left by Andy Stopford on May 24, 2007 8:34 AM

# re: CI Factory with NUnit (rather than MbUnit)

Requesting Gravatar...
As I mentioned - it was mainly the documentation issue. I work on a laptop quite a bit, with internet access not being guaranteed. Although the wiki is comprehensive, having off-line documentation (which NUnit has) is very useful. I suppose I could use the NUnit docs for MbUnit as they use the same basic syntax.

It's also probably lethargy. I've used NUnit previously (although only occasionally ) and I already had it installed and ready to go on my development PC. I was trying to get up to speed on CI Factory, and was keen to reuse any knowledge I already had.

I just had a peep at the MbUnit GUI and I'll resolve to have a better look at your framework in the future.

However, there is some sense of satisfaction in using two different unit testing frameworks. Currently my development PC runs tests using NUnit, the build server with MbUnit. That means two different frameworks performing the same unit tests which is even more 'thorough' than using a single testing framework. ;-)


Liam Westley
Left by Liam Westley on May 28, 2007 11:13 PM

# NUnit Test Generator

Requesting Gravatar...

I recently created a tool to generate NUnit tests. I would like to get your opinion of it and also any suggestions for features. See the URL below.
Left by Greg Finzer on Sep 28, 2007 4:43 AM

# re: CI Factory with NUnit (rather than MbUnit)

Requesting Gravatar...
Im facing the same problem. How did you manage to solve it?
Left by Hemal on Oct 29, 2008 12:19 PM

# re: CI Factory with NUnit (rather than MbUnit)

Requesting Gravatar...

Just created a new CI Factory installation today, and I decided to write down all the steps so you can see how I did it.

1. Standard CI Factory install, although I edited OpenSolution.Script.xml and removed <call target="Workspace.CheckForRequieredSoftware"/> as I'm using VS2008, and don't want VS2005 SP1 warning. I also copied NUnit 2.4.8 into 'c:\projects\myproject\Current\Third Party' and checked it into my version control with all the other project items.

2. I opened my solution in VS2008 and let the conversion do it's job.

3. In the solution in VS2008, I created a solution folder called 'Unit Test'.

4. In the new solution folder, I created a new class library project called 'DataAccessTests', saving it in 'c:\projects\myproject\Current\Product\UnitTest\DataAccessTest'

5. I then added the following references to 'DataAccessTests' project by browsing to the DLLs; NUnit.Framework.dll and MbUnit.Framework.dll in my 'Third Party' folder.

6. In the 'DataAccessTests' project I renamed 'Class1.cs' to 'MyTests.cs' and then added 'using NUnit.Framework' to support writing unit tests with NUnit.

7. I attributed the the MyTests class with [TestFixture] and created two unit tests; one designed to pass, one to fail.

8. I compiled the solution on my developement machine and used the NUnit GUI to test the new test assembly. Once passed on the development system I checked the solution files into my version control.

9. When CC.NET picks up the changes and builds the project it runs the unit tests with MbUnit on the project, and should obtain the same results as you had on the development system.

Note: you can only use attributes and Assert statements within your unit tests that are compatible with BOTH NUnit and MbUnit. It is only because the core standard unit test operations are identical between the two testing frameworks that this works.

Hope that helps,

Left by Liam Westley on Dec 16, 2008 9:14 PM

Your comment:

 (will show your gravatar)