1

我正在尝试使用 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 (
                       ^
4

3 回答 3

1

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

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

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

于 2018-10-28T21:57:40.377 回答
0

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

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

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

于 2020-02-18T15:27:52.573 回答
0

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

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

测试结果趋势

于 2020-09-11T14:01:23.823 回答