【问题标题】:How can I publish NUnit test results using Jenkins Pipeline?如何使用 Jenkins Pipeline 发布 NUnit 测试结果?
【发布时间】:2017-12-08 18:18:04
【问题描述】:

尝试使用漂亮的 Jenkins 流水线时,我在寻找如何发布 NUnit 测试结果时遇到了问题。

我可以通过在管道脚本中指定以下命令来运行测试:

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

但是如何让 Jenkins “发布”测试结果并不明显。 Snippet Generator 只建议 junit,这似乎不起作用。

【问题讨论】:

    标签: jenkins nunit jenkins-pipeline


    【解决方案1】:

    我使用了 nunit 插件版本 0.21,并且能够使用

    发布结果
    stage("PublishTestReport"){
         nunit testResultsPattern: 'TestResult.xml'
         }
    

    (TestResult.xml 在上例中位于 jenkins 工作区的根目录)

    【讨论】:

    • 这个问题好像已经解决了。
    • @OlaEldøy 你能接受这个答案吗?它有助于查看问题是否已得到解答。
    • 我真希望他们能把这个放在前面,放在他们的plugin page 的中心 - 感谢您在此处添加此内容!
    【解决方案2】:

    研究 Jenkins 的 NUnit 插件后,我找到了this issue,在那里我找到了解决方案:

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

    将此添加到管道脚本对我有用!

    但是,以下方法似乎也应该起作用(但目前,显然它不起作用):使用 Snippet Generator,选择此:

    step: General Build Step
    Publish NUnit test result report
    

    这会在管道脚本中生成以下内容:

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

    这失败了!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多