Forum Discussion

_ivanovich_'s avatar
_ivanovich_
Frequent Contributor
5 years ago

How to get JDBC teststep assertion status using groovy ?

Hi,

 

i have a JDBC step in my test.

In my JDBC step i added NotContains Assertion with : <ResultSet fetchSize="0"/>

So if the assertion fails the JDBC step becomes Red and the test stops.

 

Is it possible to write a groovy code which will get the content of ResponseAsXml property in a file inside the scritp assertion of the JDBC step?

In this way i can know what happen in my txt file

 

I tried this in script assertion of the jdbc step:

def testCase = messageExchange.modelItem.testCase['mytestcase'].testSteps['myjdbc'];
def result = testCase.testSteps.getPropertyValue("ResponseAsXml");
log.info result

 

it says: No such property: mytestcase for class: com.ewiware.soapui.impl.wsdl.testcase.WsdlTestCase

 

Thank you

 

 

 

 

 

 

1 Reply

  • _ivanovich_'s avatar
    _ivanovich_
    Frequent Contributor

    Found solution with this:

    def data = testRunner.testCase.getTestStepByName("teststepname").getPropertyValue("ResponseAsXml")

    But we have to add in a groovy step separately from the JDBC step.

    The script assertion with this code inside JDBC won't work in open source version as i understand.

    So i need another groovy setp to achieve the goal.

    Thanks