【问题标题】:Groovy script for set description on Jenkins Junit test results用于 Jenkins Junit 测试结果集描述的 Groovy 脚本
【发布时间】:2019-02-18 08:59:25
【问题描述】:

我不知道如何使用 groovy 脚本设置 PASS 或 FAIL 测试用例的描述: 我可以使用这个 groovy 代码为“All tescase”或 Jenins 构建设置描述,但测试结果对我不起作用:

def testResults = manager.build.getAction(hudson.tasks.junit.TestResultAction.class).getResult()
def buildVersion = manager.envVars["BuildVersion"]
testResults.setDescription(buildVersion)

    testResults.getChildren().each { packageResult -> 
         packageResult.setDescription(buildVersion)
         packageResult.getChildren().each { testcase -> 
              testcase.setDescription(buildVersion)    

     }
    }

有人可以帮我解决这个问题吗...?! 谢谢!

【问题讨论】:

    标签: jenkins groovy junit


    【解决方案1】:

    此代码适用于我:

    def testResults = manager.build.getAction(hudson.tasks.junit.TestResultAction.class).getResult()
    def failed = manager.build.getAction(hudson.tasks.junit.TestResultAction.class).getFailedTests()
    def passed = manager.build.getAction(hudson.tasks.junit.TestResultAction.class).getPassedTests()
    def buildVersion = manager.envVars["BuildVersion"]
    testResults.setDescription("PASS")
    testResults.getChildren().each { packageResult -> 
         packageResult.setDescription("PASS")
         packageResult.getChildren().each { testcase -> 
              testcase.setDescription("PASS")    
                   failedTests = testResults.getFailedTests();   
                        failedTests.each { test ->
                    test.setDescription("FAIL")
           }
        passedTests = testResults.getPassedTests();
           passedTests.each { test2 ->
                    test2.setDescription("PASS")
           }
     }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-13
      相关资源
      最近更新 更多