Write log file from all loop request when executing test-case
I'm new in SOAP UI testing and I have one questions according to log files. I have wrote groovy script, which with loop make some requests, and I need to write all requests result in one txt file. Maybe some suggestions from experienced users, please? :)
Thank you!
P.S - Maybe I can somehow automatically with groovy script save http log after request is done?
Hi,
I put the logging into a tearDownScript and go through all results of the test steps included in the test case.
I log the content of the request and response:
File outDir = new File(testRunner.testCase.testSuite.project.getPropertyValue( "outputDirectory") + "/" + testRunner.testCase.testSuite.getName() + "/" + testRunner.testCase.getName()) outDir.mkdirs() File responseFile File requestFile i = 1 def stepNum = 1 testRunner.results.each { // WsdlTestRequestStepResult if (it instanceof WsdlTestRequestStepResult) { requestFile = new File(outDir, it.getTestStep().getName() + "-" + stepSetNumber(i, testStepsCount) + "-Request.xml") responseFile = new File(outDir, it.getTestStep().getName() + "-" + stepSetNumber(i, testStepsCount) + "-Reponse" + "-" + it.getStatus() + ".xml") requestFile << it.getRequestContent() responseFile << it.getResponseContent() } i++ }
You can also make a simple reporting CSV, which contains a status for each test step, e.g. (the iterator 'it' goes over testRunner.results):
def resultLine = testRunner.testCase.testSuite.getName() + ":" + testRunner.testCase.getName() + ":" + it.getTestStep().getName() + ":" + it.getStatus() + ":"
The code above belongs to WSDL/SOAP services, co you may need to accomodate it for REST.
Karel