I used NUnit Runner in Atlassian Bamboo (latest version) with NUnit 2 but after upgrading to NUnit 3 it is no longer working. It appears something changed with the command line in NUnit 3. Anyone know how to make NUnit 3 work in Atlassian Bamboo? Or could the NUnit devs consider backward compatibility for this breaking change?
I get the following error:
Invalid argument:
-xml=TestResults-Rev_02f5436a0a70cd539bd3b77218fb48cbe3262954-Build_12.xml
Thank you
The simplest solution is to create a bat file that replaces -xml argument to --result.
Create a bat file in Nunit runner directory (by default C:\Program Files (x86)\NUnit.org\nunit-console) and copy the fallowing lines into it.
@echo off
SET "var=%*"
CALL SET var=%%var:-xml=--result%%
nunit3-console.exe %var%;format=nunit2
Then use the bat file address as Nunit runner executable path.
Hopefully the Atlassian team will update Bamboo to support NUnit 3 soon. I would suggest submitting a request with them. The NUnit team will be happy to help them if they have any questions.
NUnit will not support a backward's compatible command line, but you can likely get Bamboo working now by modifying the test execution task.
I haven't used Bamboo, but on AppVeyor, we had to disable automatic test detection and running, then instead of using the built in NUnit task, we execute the new nunit3-console directly, passing in the test assemblies.
If Bamboo parses and displays the test results, you can instruct NUnit 3 to produce XML in the version 2 format with the command --result=TestResults.xml;format=nunit2
Also, fyi, the -xml option has been deprecated for 3 years!
I assume that bamboo generates command-line options for NUnit based on settings provided by the user. Because NUnit 3.0 is such a large change from the v2 series, the developers may want to treat it as an entirely new framework. In fact, the NUnit 3.0 engine does exactly that, treating NUnit V2 as a "foreign" framework and using a special driver to run its tests.
You are getting that issue as the nunit-3
does not use the -xml
flag anymore and is replaced by --result
. The bamboo nunit runner is not udpated and still generates the flag used by the old nunit.
Create a bat file with the following contents. Instead of using the nunit executable in bamboo, use the bat file.
@echo off
SET projectvar=%1
SET xmlvar=%2
SET executable=C:\Program Files (x86)\NUnit-3.4.1\bin\nunit3-console.exe
CALL SET xmlvar=%%xmlvar:-xml=--result%%
SET outputvar=%3;format=nunit2
SHIFT
SHIFT
SHIFT
SET remvar=%1
:loop
SHIFT
if [%1]==[] GOTO afterloop
SET remvar=%remvar% %1
GOTO loop
:afterloop
%executable% %projectvar% %xmlvar% %outputvar% %remvar%