简体   繁体   中英

How can I publish NUnit test results using Jenkins Pipeline?

Trying to use the nifty Jenkins Pipeline, I had problems finding out how to publish NUnit test results.

I am able to run the tests by specifying the following command in the pipeline script:

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 make Jenkins "publish" the test results is not obvious. The Snippet Generator only suggests junit, and that does not seem to work.

I used nunit plugin version 0.21 and was able to publish results using

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

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

Investigating the NUnit plugin for Jenkins led me on to this issue , where I found the solution:

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

Adding this to the pipeline script worked for me!

However, it seemed the following should also work (but at the present, apparently, it does not): Using the Snippet Generator, select this:

step: General Build Step
Publish NUnit test result report

This generates the following in the Pipeline script:

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

This fails!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM