How to run NUnit Runner in Atlassian Bamboo with NUnit 3

I used NUnit Runner in Atlassian Bamboo (latest version) with NUnit 2, but after upgrading to NUnit 3 it no longer works. Something seems to have changed with the command line in NUnit 3. Does anyone know how to get NUnit 3 to work in Atlassian Bamboo? Or could NUnit developers consider backward compatibility for this violation?

I get the following error:

Invalid argument: -xml = TestResults-Rev_02f5436a0a70cd539bd3b77218fb48cbe3262954-Build_12.xml

thanks

+7
unit-testing atlassian bamboo nunit-console
source share
4 answers

The easiest solution is to create a bat file that replaces the -xml argument with -result.

Create a bat file in the Runner Nunit directory (the default is C: \ Program Files (x86) \ NUnit.org \ nunit-console) and copy the parrying lines into it.

@echo off SET "var=%*" CALL SET var=%%var:-xml=--result%% nunit3-console.exe %var%;format=nunit2 

Then use the bat bat file as the Nunit runner executable path.

+7
source share

We hope that the Atlassian team will update Bamboo to support NUnit 3 in the near future. I would suggest sending a request with them. The NUnit team will be happy to help them if they have any questions.

NUnit does not support a backward compatible command line, but now you can get Bamboo to work by changing the task of running the test.

I did not use Bamboo, but on AppVeyor we had to turn off the automatic detection and launch of the test, instead of using the built-in NUnit task, we launch the new nunit3 console directly, passing the test builds.

If Bamboo parses and displays the test results, you can instruct NUnit 3 to create XML in version 2 format with the command --result=TestResults.xml;format=nunit2

+1
source share

Also, fyi, the -xml option has been deprecated for 3 years!

I assume that bamboo generates command line options for NUnit based on the settings provided by the user. Since NUnit 3.0 is such a big change from the v2 series, developers may want to consider it as a completely new structure. In fact, the NUnit 3.0 engine does just that, considering NUnit V2 as a "foreign" structure and using a special driver to run its tests.

+1
source share

You get this problem since nunit-3 no longer uses the -xml flag and is replaced with --result . The bamboo nunit runner is not fooled 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% 
0
source share

All Articles