How do you run nunit tests in Bamboo?

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
Joseph Clark Atlassian Team Jun 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="">

<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" />



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.

Joseph Clark Atlassian Team Jun 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:

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! :-)

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 Join to answer
Community showcase
Jason Wong
Published yesterday in Agility Beta

Welcome to agility

Every team in the world is unique, and so   Atlassian believes   that each and every team's best way of working  needs to  be molded to their unique circumstances  – ...

383 views 6 16
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot