使用 Jenkins 管道在 Jenkins 控制台上打印失败的测试数据

问题描述 投票:0回答:1

我找不到任何方法使用 Robot 插件或通过解析 output.xml 在 Jenkins 控制台上打印机器人框架结果的失败测试标签、测试名称、原因等

正如ChatGPT建议的那样,我尝试将output.xml输入到jenkins管道中机器人插件的robot()中。 但我没有得到这样的属性 failedTests



pipeline {

    agent any

    stages {

        stage('Robot Test') {

            steps {

                script {

                    // Run Robot Framework tests

                    sh 'robot --outputdir results tests'

                    // Parse the Robot Framework output XML file

                    def robotOutput = robot(

                        inputFile: 'results/output.xml',

                        outputPath: 'robot-reports',

                        logFileName: 'log.html',

                        reportFileName: 'report.html',

                        outputFileName: 'output.xml'

                    )

                    // Print failed tags

                    robotOutput.failedTests.each { failedTest ->

                        failedTest.tags.each { tag ->

                            println("Failed tag: ${tag}")

                        }

                    }

                }

            }

        }

    }

}
jenkins jenkins-pipeline robotframework jenkins-groovy
1个回答
0
投票

最简单的方法是使用 junit 插件:https://plugins.jenkins.io/junit/ 一个例子:

 dir ("app/test-results") {
      junit allowEmptyResults: true, skipPublishingChecks: true, testResults: '*'
 }
© www.soinside.com 2019 - 2024. All rights reserved.