Scott Hanselman

Calling NUnit from NAnt Pragmatically

January 26, '06 Comments [2] Posted in Learning .NET | ASP.NET | NUnit | Nant | Tools
Sponsored By

Often times when calling NUnit tests from NAnt scripts we use the nunit2 NAnt task. However, as NAnt version march on and NUnit versions do as well, one gets into assembly binding problems. You might using NUnit 2.2.6.0 and NAnt's compiled with 2.2.0.0. This can be solved with assembly binding redirects but, eh. Poo.  This week on the XP Mailing List Charlie Poole said this:

If it's not too much trouble, revise your testing target to use <exec> rather than <nunit2> Since my copy of NUnit itself is continually evolving, I use <exec> for testing NUnit. You could also keep both targets in the script, since the task will most likely be upgraded soon. - Charlie Poole

I'd been avoiding having to call NUnitConsole.exe from the exec task just because it felt "icky." However, seeing that Charlie and he has +1 Charisma when attacking with NUnit, I am rethinking my objections. Then he added:

One bit of good news: we're working on creating a stable interface for tools
like Nant to use across NUnit versions. - Charlie Poole

Yay! I await it eagerly. While you're reading this, go get TestDriven.NET and start reading Jamie Cansdale's Blog. I'm surprised more people aren't impressed that his stuff supports the Express SKUs considering that Add-Ins aren't supported (explicitly locked out) with Express.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. I am a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Thursday, January 26, 2006 2:04:45 AM UTC
It's about time they implemented a stable interface. The change between v1 and v2 was pretty drastic and actually quite funky, as the NUnit test runners actually implemented lots of stuff that the nunit1 task in nant already implemented externally, but with somewhat different "style", which meant that making the stuff that was in nunit1 task functional under the nunit2 task was quite a hassle :)

Besides, I'm I the only one that things that NUnit should finally start settling down on a core interface with a more "fixed" assembly version that doesn't change with every single release, no matter how small the changes? :)
Thursday, January 26, 2006 1:29:37 PM UTC
Personally, I use NCover to call NUnit to get around this issue - kinda like a "two-fer" ;) That being said, it will be nice to have a little more stability in the interface.
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.