PDA

View Full Version : NUnit


peter.major
11-17-2003, 06:14 AM
Hi all.

I have been tasked with evaluating automated build software with a view to implement daily (or more) builds into our process for the next version of the product (built in VS.Net).

Visual Build is refreshing compared to some of the other tools out there. The built-in tasks mean that I can set up a prototype build in a couple of hours, as compared to the days it took to figure out NAnt.

The ONLY thing that seems to be missing in regards to what we need is closer integration with NUnit - which IMHO is pretty much the defacto unit testing tool for .Net applications.

I guess I can fool around with "Run program" task and try to parse NUnit output to get some feedback... but it kind of defeats the whole purpose of why I like Visual Build - that I can get everything working in a couple of hours.

Maybe I'm missing the point... Can anyone advise me on their experience of using NUnit with Visual Build?

Kindest regards,
Pete
peter.major_AT_ivisgroup.com

kinook
11-17-2003, 09:44 AM
Hey, we can't think of everything :^). NUnit takes only 1 to 3 command-line parameters (see http://nunit.org/commandLine.html), so it should be pretty simple to create a Run Program step for it. Console apps typically return a non-zero exitcode on failure (hopefully Nunit does too), so you shouldn't need to parse the output, since the Run Program action will fail on a non-zero exitcode.

peter.major
11-17-2003, 10:50 AM
Thanks for your prompt reply. A couple of things:

- You are indeed correct - NUnit does use return codes. And after exploring the product more I discoved how to send email notifications on failure with the console output... I would have prefered to have a task instead of having to figure it out myself, but hey that's life as a developer I guess.

- I realize that you can't make tasks for everything... there's a lot of products out there. Saying that however, I've used NUnit for the last companies that I've worked for. My experience is that it is pretty much THE testing tool for .Net development. Just seems a bit odd that there is no task for it. Saying that it can be done from the command line is a bit of a dull argument, after all I can use the command line to get the latest version of files from VSS rather than use your task if I really wanted to (but thank goodness I didn't have to)

- I'd love to hear from anyone who's used this product with NUnit and their experiences, maybe any tips and tricks they're using.

It seems like a great product though - a lot easier to use than NAnt! Keep up the good work.

Pete

a_t_jackson
06-10-2004, 12:16 PM
I'm using NUNIT 2.1 and it very easy to integrate with VisualBuild. I have a "Run Program" action that calls the command line version of nunit, and passes in the path to the dll that it needs to test, something like:

C:\Program Files\NUnit V2.1\bin\nunit-console.exe "blah\bin\Release\mynunitproject.dll"

NUNIT returns zero as the exit code if tests pass, and non-zero otherwise, and the "Run Program" action automatically checks that.

In practice I have a have a single C# solution that contains a number of sub projects for a n-tier application. This solution contains nunit projects for each tier. I adopted the convention of naming the project nunitDataLayer.csproj, nunitBusinessLogic.csproj etc.

Developers typically work on one part of the code at a time and therefore only run one nunit project. Visual Build ensures all of nunit projects are alsoways re-run as part of the build process.

JohnLiu
10-04-2004, 08:06 PM
Slight modification, I think this one works. Not 100% sure whether that's the right key.

Run Program Task

%REG_READ("HKLM\SOFTWARE\Microsoft\.NETFramework\AssemblyFold ers\NUnit.Framework\")%\nunit-console.exe %path_to_your%test.nunit

dkallen
11-11-2004, 06:37 PM
Thanks John, your registry read is very convenient
and will save us time when we upgrade versions of NUnit.

Your technique worked perfectly.
I merely created a "Run Program" step
and pasted your HKEY thingy into it and replaced the argument with my test dll.

No further adjustments were needed to check error codes and such. It just works as expected.

JohnLiu
11-11-2004, 09:11 PM
we had the issue when some people in the office had NUnit 2.1 and others had 2.2

glad it helped.