How do you run nunit tests in Bamboo?

Paul Rempel June 29, 2011

I have a .NET Solution that is built in Bamboo (3.03) using the MSBUILD builder. That builds several assemblies including some nunit test assemblies. I want to run nunit and generate test results after the solution file is built successfully.

How do you do this? Ie. What builder should I use? Do I need multiple Jobs for the Plan? And does the procedure change if I upgrade to a newer version of Bamboo?

I've tried creating a second Job which will run nunit-console.exe after the first Default Job has built the assemblies. The problem is that when the second job runs, it is in its own subfolder with a new copy of the repository files, which does not include the freshly compiled dll's from the previous Job.

2 answers

1 accepted

2 votes
Answer accepted
Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 29, 2011

EDIT: I thought there was built-in support for running NUnit tests in Bamboo 3.1, but I was stupidly mistaken. There is a built-in test result parser, but shelling out to a batch script or a custom MSBuild task is still the "best" way to go for now.

-------------------------

If you're able to upgrade to Bamboo 3.1, there is built-in support for running NUnit Tests and parsing NUnit XML Result files as stand-alone tasks in a build. Check out the release notes.

Otherwise, I think the easiest solution is to edit your MSBuild file and use the MSBuild Community Tasks to call NUnit to execute your tests. For example, a skeleton implementation of this in MSBuild would look something like this:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<Import Project="lib\MSBuild.Community.Tasks.Targets" />

<Target Name="Test">

<NUnit Assemblies="bin\Debug\MyAssemblyToTest.dll" ToolPath="C:\Program Files\NUnit 2.5.10\bin\net-2.0" OutputXmlFile="bin\Debug\TestResults.xml" />

</Target>

</Project>

Paul Rempel June 29, 2011

I'll try upgrading to 3.1. From the release notes it looked to me like it was just an NUnit Parser to parse results, not necessarily to run it. I'd be happy to upgrade if it lets me run the tests!

I'm trying to avoid changing the build file so that they don't run on every developer build automatically (I know I can use conditional testing to only run in on Release builds), but I'll do it that way if I have to. Thanks.

Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 30, 2011

Darn, you're right. I thought there was a new task just for running NUnit tests, but I must have imagined it!

You could configure a stand-alone task to run a custom MSBuild file that is not part of the main solution, so it won't run as part of every developer's build. Something like this: http://screencast.com/t/vT9MIUXI7tAL


I know I'm probably sounding like a sales pitch, but the tasks configuration in 3.1 is really flexible and I think it's awesome! :-)

0 votes
James Dumay
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 30, 2011

There is an issue open to introduce an nunit runner to the Bamboo .NET Plugin. Please vote, comment and harass us about it on the issue!

The .NET plugin is open source too - so if your feeling adventureous you could hack a runner together pretty easily :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events