以下是拆卸脚本,用于从套件拆卸中获取所有测试用例计数和状态,但是我需要从项目拆卸中获取整体测试套件计数和状态,但是不幸的是,它将不支持测试运行器类的对象
def failedTestCases = 0
runner.results.each { testCaseResult ->
def name = testCaseResult.testCase.name
if(testCaseResult.status.toString() == 'FAILED') {
failedTestCases++
log.info "$name has failed"
testCaseResult.results.each { testStepResults ->
testStepResults.messages.each { msg -> log.info msg }
}
} else {
log.info "$name works correctly"
}
}
答案 0 :(得分:0)
在您的项目上,创建一个安装脚本:
project.setPropertyValue("testcasesRun","0")
project.setPropertyValue("testcasesFailed","0")
在每个TestSuite上,按照以下步骤创建一个TearDown脚本:
def failedTestCases = 0
def testCasesRun = 0
runner.results.each { testCaseResult ->
testCasesRun++
if(testCaseResult.status == com.eviware.soapui.model.testsuite.TestRunner.Status.FAILED) {
failedTestCases++
}
}
def existingFailedTestCases = new Integer( runner.testSuite.project.getPropertyValue("testcasesFailed") )
def newFailedValue = existingFailedTestCases + failedTestCases
runner.testSuite.project.setPropertyValue("testcasesFailed",newFailedValue.toString())
def existingRunTestCases = new Integer( runner.testSuite.project.getPropertyValue("testcasesRun") )
def newRunTestCases = existingRunTestCases + testCasesRun
runner.testSuite.project.setPropertyValue("testcasesRun",newRunTestCases.toString())
运行项目后,您应该具有两个“项目属性”,分别包含已计数的测试用例和失败的测试用例的数量。