How to run NUnit Runner in Atlassian Bamboo with NUnit 3?
Asked Answered
U

4

8

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

Ulster answered 2/12, 2015 at 21:49 Comment(1)
Try to use my variant described here #40088402Preponderance
C
8

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.

Convertible answered 30/1, 2016 at 12:41 Comment(3)
I am getting an error saying that nunit3-console.exe is not a recognized command @ConvertibleDearly
Sorry for late answer, if you have installed unit runner 3 you should have nunit3-console.exe in the installation folder (be default C:\Program Files (x86)\NUnit.org\nunit-console) and you should but the bat file in the same folder as well, so bat file should be able to file nunit3-console.exe, by the way you can try using full path for nunit3-console.exe as well.Convertible
Put quotes around the command if the path contains spaces. The last statement then looks like this: "%~dp0nunit3-console.exe" %var%;format=nunit2Glacier
J
1

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

Jadotville answered 2/12, 2015 at 22:9 Comment(0)
L
1

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.

Languish answered 2/12, 2015 at 22:23 Comment(0)
E
0

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%
Esdraelon answered 11/4, 2017 at 4:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.