How to run NUnit Runner in Atlassian Bamboo with NUnit 3?

≡放荡痞女 提交于 2019-12-30 06:26:25

问题


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


回答1:


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.




回答2:


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




回答3:


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.




回答4:


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%


来源:https://stackoverflow.com/questions/34053704/how-to-run-nunit-runner-in-atlassian-bamboo-with-nunit-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!