在SOAP UI项目中使用Groovy创建摘要报告的步骤如下:
import com.eviware.soapui.model.testsuite.TestRunner.Status
def testStep = testRunner.testCase.getTestStepByName("YourTestStepName")
def status = testStep.testRequest.response.status
if (status == Status.FAILED) {
log.error("Test Step failed: " + testStep.name)
} else if (status == Status.CANCELED) {
log.warn("Test Step canceled: " + testStep.name)
} else {
log.info("Test Step passed: " + testStep.name)
}
def summaryReport = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testRunner.testCase, null)
summaryReport.runTestStepByName("YourTestStepName")
def summary = summaryReport.getSummary()
def totalTests = summary.getTestCount()
def failedTests = summary.getFailedCount()
def canceledTests = summary.getCanceledCount()
def successRate = (totalTests - failedTests - canceledTests) / totalTests * 100
log.info("Summary Report:")
log.info("Total Tests: " + totalTests)
log.info("Failed Tests: " + failedTests)
log.info("Canceled Tests: " + canceledTests)
log.info("Success Rate: " + successRate + "%")
请注意替换代码中的"YourTestStepName"为您要创建摘要报告的测试步骤的名称。
这样,您就可以在SOAP UI项目中使用Groovy创建摘要报告了。
领取专属 10元无门槛券
手把手带您无忧上云