Friday 29 April 2016

Output nunit2 compatable xml from the nunit3 console runner in your CI pipeline.

Upgrades

We have recently upgraded many of our .net projects to use C#6 and .net 4.6.1. At the same time we upgraded nunit to nunit3 on all our build servers. Problem was that GoCd (our CI server) doesn't recognize the new nunit3 result format, only the older more ubiquitous junit/nunit2 xml format. whilst failing tests would cause the build to break you had to dig into the console output to see the failures rather than looking in the tests tab.

Investigation

The solution to the problem was to get the nunit3 console runner to output results xml in the old nunit2 style, easier said than done. The documentation for the runner is actually quite bad in this regard. All it says is: "The --result option may use any of the following formats. nunit2" but doesn't actually show how. I ended up in the source code for the nunit3-console.tests and saw the answer burred within.

Solution

The final command i ended up with is as follows:
nunit3-console --result:"Result.xml;format=nunit2" --where "cat!=Integration" .\tests.dll
This output was then able to be imported into Go and we again get visibility of the numbers of tests run, passing and failing on the go server.

Thanks to all who responded on the google group discussion pointing me in the right direction.

3 comments:

  1. Reports are geeting generated as nunit 2 xml format but still not able to view passed in bamboo... any suggestion?

    ReplyDelete
    Replies
    1. & 'C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe' --result="C:\tests\TestResults.xml;format=nunit2" "C:\test\site\Test.dll" --params:Browser=Chrome --where "cat == Parallel"


      am using this command... can you help?

      Delete
    2. I've never used Bamboo so im at a disadvantage but i can make some suggestions:

      Have you ever visualized any nunit 2 xml using bamboo, if so can you compare the output from your command to the working files and see what the differences are.

      If you have never had bamboo working with regard to visulising these files my question is can it? does it need nunit 3 version xml? does it need a plugin or some other configuration. id try and get some valid xml from the internet and add it as a static file to try and see if bamboo really does work with a verified xml file of the type you are supposedly generating. Basically you need to know is it a problem with bamboo or with your generated file.

      Delete