VGaur
10 years agoContributor
Print raw request and response in stack trace on test case failure
Hello Peeps, I want to print the raw request and response in the stack trace when a test case fails.How can I do that?? Cheers, Varun
- 10 years ago
Noticed this question as part of August News Journal. At times it is possible to miss some question. Thanks for the journal for better followup.
Here is the script that can used in Tear Down for test case.
import com.eviware.soapui.model.testsuite.TestRunner.Status def logRawData = { stepName -> def step = testRunner.testCase.getTestStepByName(stepName) def rawRequest = new String(step.testRequest.messageExchange.rawRequestData) def rawResponse = new String(step.testRequest.messageExchange.rawResponseData) log.error rawRequest log.error rawResponse } if (testRunner.status == Status.FAILED) { //You need to provide the request step name and you can repeat the same
//statement with different step name in case of multiple steps for a test case logRawData('Test Request1') logRawData('Test Request2') }Hope this is useful