Ross
Ross

Reputation: 2417

Log Test Step response using groovy script in SoapUI

I currently have a test suite with 76 Soap test steps in which all have been run. however in the logs I am getting the test step name as expected but no the response.

Both the groovy script and the test steps are in the same test suite but different test cases. It has the following structure:

Groovy Script:

def testCases = context.testCase.testSuite.getTestCaseList()
testCases.each
{

    for(testSteps in it.testStepList)
    {
        log.info "~~~Test Step:" + testSteps.name
        def requestname = testSteps.name
        log.info context.expand('${'+requestname+'#Response}')
    }
}

Logs:

Tue Mar 21 11:50:04 GMT 2017:INFO:~~~Test Step:TestStep_0001
Tue Mar 21 11:50:04 GMT 2017:INFO:
Tue Mar 21 11:50:04 GMT 2017:INFO:~~~Test Step:TestStep_0002
Tue Mar 21 11:50:04 GMT 2017:INFO:
Tue Mar 21 11:50:04 GMT 2017:INFO:~~~Test Step:TestStep_0003
Tue Mar 21 11:50:04 GMT 2017:INFO:

Why am I not getting the data that is in the response for each test step?

Upvotes: 2

Views: 3390

Answers (1)

Rao
Rao

Reputation: 21389

Here is the Groovy Script, which does what you are looking for: Key is to use step.getPropertyValue('Response')

import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep
//Repeat thru test cases
context.testCase.testSuite.testCaseList.each { tc ->
    tc.testStepList.each { step ->
        log.info "~~~Test Step:" + step.name 
        if (step instanceof WsdlTestRequestStep) {
            log.info step.getPropertyValue('Response')  
        } else {
            log.info 'Ignoring step as it is not SOAP request type step'
        }
    }
}

Upvotes: 2

Related Questions