How can I publish NUnit test results using Jenkins Pipeline?

Trying to use the excellent Jenkins pipeline, I had trouble finding the results of publishing NUnit results.

I can run the tests by specifying the following script command in the pipeline:

stage 'Test' bat '"C:\\Program Files (x86)\\NUnit 2.6.4\\bin\\nunit-console-x86.exe" "ProjectName\\bin\\Release\\UnitTests.net.dll"' 

But how to get Jenkins to “publish” the test results is not obvious. The fragment generator offers only junit, and this does not seem to work.

+6
source share
2 answers

Researching the Nunit plugin for Jenkins led me to this problem , where I found a solution:

 step([$class: 'NUnitPublisher', testResultsPattern: 'TestResult.xml', debug: false, keepJUnitReports: true, skipJUnitArchiver:false, failIfNoResults: true]) 

Adding this to the script pipeline worked for me!

However, it seemed that the following should also work (but currently, apparently, this is not the case): using the fragment generator, select this:

 step: General Build Step Publish NUnit test result report 

This creates the following in the Pipeline script:

following:
 step <object of type hudson.plugins.nunit.NUnitPublisher> 

It fails.

+10
source

I used nunit version 0.21 and was able to post the results using

 stage("PublishTestReport"){ nunit testResultsPattern: 'TestResult.xml' } 

(TestResult.xml is in the root jenkins workspace in this example)

+3
source

Source: https://habr.com/ru/post/1012336/


All Articles