【问题标题】:MSTest .trx file display using Xunit Plugin and Jenkins Piepline使用 Xunit Plugin 和 Jenkins Pipeline 显示 MSTest .trx 文件
【发布时间】:2019-02-11 03:20:56
【问题描述】:

我正在尝试使用 Xunit 插件和 Jenkins 管道显示 MStest、Nunit3、Nunit2 结果,但没有成功。 我找不到 Xunit 插件的正确文档以及所有所需的参数。

我得到了以下链接,但它们没有多大帮助 https://www.cloudbees.com/blog/xunit-and-pipeline https://wiki.jenkins.io/display/JENKINS/xUnit+Plugin

有人知道如何使用 Xunit 插件在 jenkins 管道中显示 mstest、nunit3 和 nunit2 结果吗?

以下是我用于 MStest 报告解析并出现错误的代码。 我对 Jenkins 中的管道非常陌生,非常感谢任何帮助/指针!提前致谢!!

以下是我的管道代码

pipeline {
    agent any
    stages {
        stage('Copy Test Reports') {
            agent {
                node {
                    label 'test'
                    customWorkspace "C:\\jenkins\\workspace\\tests"
                }
            }
            steps {
                echo 'Hello world!'
                bat '''copy \\\\Precheck.xml .
                copy \\\\*.trx .'''
            }
            post {
                always {
                    xunit (
                        thresholds: [$class: 'FailedThreshold', unstableThreshold: '1'],
                        tools: [$class: 'MSTest', pattern: '*.trx']
                    )
                }
            }
        }        
    }
}


Error:
Missing required parameter: "thresholdMode" @ line 19, column 21.
                       xunit (
                       ^

WorkflowScript: 19: Missing required parameter: "testTimeMargin" @ line 19, column 21.
                       xunit (
                       ^

【问题讨论】:

标签: jenkins jenkins-plugins jenkins-pipeline xunit jenkins-mstest


【解决方案1】:

我遇到了同样的问题,但使用 GoogleTest 报告。 将缺少的参数添加到您的 xunit() 调用中应该可以解决问题:

                xunit (
                    testTimeMargin: '3000',
                    thresholdMode: 1,
                    thresholds: [$class: 'FailedThreshold', unstableThreshold: '1'],
                    tools: [$class: 'MSTest', pattern: '*.trx']
                )

'3000' 和 '1' 是 xunit-plugin 内部设置的默认值。

【讨论】:

    【解决方案2】:

    我不得不用插件做一些不同的事情,所以我发布我的解决方案以防它有帮助 -

    xunit(
        [MSTest(deleteOutputFiles: true,
                failIfNotNew: true,
                pattern: '*.trx',
                skipNoTestFiles: false,
                stopProcessingIfError: true)
        ])
    

    注意,这要求您的 trx 文件位于工作区的根目录中。如果不是,您需要将它们复制到那里。

    【讨论】:

      【解决方案3】:

      是否有理由使用xunit-plugin?我使用mstest-plugin 如下,这似乎工作正常

      mstest testResultsFile:"**/*.trx", keepLongStdio: true
      

      【讨论】:

      • 使用这个命令,我得到这个错误[MSTEST-PLUGIN] INFO processing test results in file(s) **/*.trx。我想也许 MSTest 正在寻找错误的位置。然后我给出了 trx 文件的绝对路径,现在它显示SEVERE while listing workspace files: Expecting Ant GLOB pattern, but saw '/home/myuser/build/newapp-math/testResult.trx'。任何iea可能是什么问题?我正在使用 Xunit 进行单元测试。
      猜你喜欢
      • 1970-01-01
      • 2012-10-31
      • 2013-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-03
      • 1970-01-01
      • 2019-09-02
      相关资源
      最近更新 更多