Forum Discussion

rajs2020's avatar
rajs2020
Frequent Contributor
4 years ago

ReadyAPI - Return entire result set from a database ?

I have a run test case step in Test1 which calls a Test2. Test2 only has one JDBC step at the moment. I want to return the entire result set from Test2 to Test1, preferably in the form of a single "object". How do I do that? How do I access the rows and columns in that "object" via a groovy script? Something like this:

Test 2 - JDBC step :
return TableLikeObject or Json.

Test1 - Groovy test step :
TableLikeObject table = Test 2 - JDBC returned value.
table.getRow(1).getColumn('Employee name')

Test1 calls Test2.

  • rajs2020 : you can do it by following way:

    //if in same Test Case
    
    def teststep = testRunner.getTestCaseByName("TestCase2").getTestStepByName('JDBC Step')
    
    //if in different Test Case
    
    def teststep = testRunner.testCase.testSuite.getTestCaseByName("TestCase2").getTestStepByName('JDBC Step')

     

  • nmrao's avatar
    nmrao
    Champion Level 3

    1. Create a test case level custom property for Test2. Say JDBCRESPONSE.

    2. Set the value to above property when jdbc step is run.

    3. In Test1, add a "Run Test Case" step, the wizard allows which Return Properties you want from Test 2. 

  • aaronpliu's avatar
    aaronpliu
    Frequent Contributor

    Hi rajs2020 ,

     

    JDBC return a xml-like response, you can think of it as XML response and use

    import com.eviware.soapui.support.XmlHolder
    
    def teststep = testRunner.testCase.testSteps['JDBC Step']
    def response = teststep.testRequest.response.contentAsXml
    
    def holder = new XmlHolder(response)
    def node = holder.getNodeValues( "//aa/b" )

     

     

    Thanks,

    /Aaron

      • HimanshuTayal's avatar
        HimanshuTayal
        Community Hero

        rajs2020 : you can do it by following way:

        //if in same Test Case
        
        def teststep = testRunner.getTestCaseByName("TestCase2").getTestStepByName('JDBC Step')
        
        //if in different Test Case
        
        def teststep = testRunner.testCase.testSuite.getTestCaseByName("TestCase2").getTestStepByName('JDBC Step')