erki
12 years agoOccasional Contributor
Getting test results from TestCaseRunner -> WsdlRunTestCase
Hi
i am implementing a feature for my tests that would log the request and response content of my failed test steps. At the moment all I see is something like "Assertion failed" etc, but I need to see what I sent in and what was returned. I am trying to read the results with some success, the code I already have is:
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()
}
}
}
}
The problem is with the last IF (WsdlRunTestCaseTestStep). How do I get the steps that were run with results from the run context?
i am implementing a feature for my tests that would log the request and response content of my failed test steps. At the moment all I see is something like "Assertion failed" etc, but I need to see what I sent in and what was returned. I am trying to read the results with some success, the code I already have is:
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()
}
}
}
}
The problem is with the last IF (WsdlRunTestCaseTestStep). How do I get the steps that were run with results from the run context?