我不知道如何使用groovy脚本在PASS或FAIL测试用例上设置描述: 我可以使用此常规代码为“所有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)
}
}
有人可以帮我这个吗??! 谢谢!
答案 0 :(得分:0)
此代码对我有用:
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")
}
}
}