简体   繁体   English

如何使用Jenkins Pipeline发布NUnit测试结果?

[英]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. 尝试使用漂亮的Jenkins管道,我在查找如何发布NUnit测试结果时遇到了问题。

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. 片段生成器只建议junit,这似乎不起作用。

I used nunit plugin version 0.21 and was able to publish results using 我使用了nunit插件版本0.21并且能够使用发布结果

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

(TestResult.xml is at the root of jenkins workspace in this above example) (在上面的例子中,TestResult.xml位于jenkins工作空间的根目录下)

Investigating the NUnit plugin for Jenkins led me on to this issue , where I found the solution: 调查Jenkins的NUnit插件引发了我的问题 ,在那里我找到了解决方案:

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: 但是,似乎以下内容也应该有效(但目前,显然,它没有):使用Snippet Generator,选择:

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! 这失败了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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