soapui - 从WsdlRunTestCaseTestStep获取测试结果

时间:2014-05-27 12:05:57

标签: groovy soapui

我正在为我的测试实现一项功能,该功能会记录我失败的测试步骤的请求和响应内容。目前我所看到的就像“断言失败”等,但我需要看看我发送的内容和返回的内容。我试图读取结果并取得一些成功,我已经拥有的代码是:

import com.eviware.soapui.model.testsuite.*
import com.eviware.soapui.impl.wsdl.teststeps.*

def suiteRunner = (TestSuiteRunner) runner.getRunContext().getTestRunner()
def listResults = suiteRunner.getResults()
for (TestCaseRunner run : listResults){
    def stepResults = run.getResults();
    for(TestStepResult step : stepResults){
        if(!step.getStatus().toString().equals("OK")){
            def local = step.getTestStep()
            def caseName = local.getTestCase().getName();
            def modalItem = local.getModelItem() 
            log.info modalItem
            if (modalItem instanceof JdbcRequestTestStep){
                log.error "TestCase " + caseName + " step " + local.getName() + " failed"
                log.error "JDBC step failed, query was: " + local.getQuery() 
                log.error "Response content:" + local.getResponseContent() 
            }
            if(modalItem instanceof WsdlTestRequestStep){
                log.error "TestCase " + caseName + " step " + local.getName() + " failed"
                log.error "Request: " + modalItem.getTestRequest().getResponse().getRequest().getRequestContent()
                log.error "Response: " + modalItem.getTestRequest().getResponse().getContentAsXml()         
            }       
            if(modalItem instanceof WsdlRunTestCaseTestStep){
                log.error "TestCase " + caseName + " step " + local.getName() + " failed"
                def target = local.getTargetTestCase()              
            }
        }

} }

问题在于最后的IF(WsdlRunTestCaseTestStep)。如何获取运行上下文结果的步骤?

0 个答案:

没有答案