cancel
Showing results for 
Search instead for 
Did you mean: 

ReadyAPI - Return entire result set from a database ?

SOLVED
rajs2020
Frequent Contributor

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.

1 ACCEPTED SOLUTION

Accepted Solutions
HimanshuTayal
Community Hero

Re: ReadyAPI - Return entire result set from a database ?

@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')

 


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal

View solution in original post

6 REPLIES 6
nmrao
Community Hero

Re: ReadyAPI - Return entire result set from a database ?

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. 



Regards,
Rao.
sonya_m
Community Manager

Re: ReadyAPI - Return entire result set from a database ?

Thank you for the suggestion @nmrao 

 

@rajs2020 Was the advice helpful?


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
aaronpliu
Frequent Contributor

Re: ReadyAPI - Return entire result set from a database ?

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

rajs2020
Frequent Contributor

Re: ReadyAPI - Return entire result set from a database ?

@aaronpliu - thanks.

def teststep = testRunner.testCase.testSteps['JDBC Step']

Instead of doing that, how do I do this:

def teststep = testRunner.testCase["TestCase2"].testSteps['JDBC Step']


I saw some documentation, but its not quickly clear how I can do something like that.
https://www.soapui.org/docs/scripting-and-properties/tips-tricks/

 

 

HimanshuTayal
Community Hero

Re: ReadyAPI - Return entire result set from a database ?

@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')

 


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal

View solution in original post

rajs2020
Frequent Contributor

Re: ReadyAPI - Return entire result set from a database ?

@HimanshuTayal- Thanks. I tried it, but could not get the Xpath to work.

import com.eviware.soapui.support.XmlHolder;

def teststep = testRunner.testCase.testSuite.getTestCaseByName('GetDBData').getTestStepByName('GetData')
def response = teststep.testRequest.response.contentAsXml


def holder = new XmlHolder(response)
def xPathQuery = "//Results/ResultSet/Row[@rowNumber='2']"
def node = holder.getNodeValues(xPathQuery)
log.info(node.toString())


I have tested my xpath on http://xpather.com/ and it is correct. So, why am I getting an array with only one empty string?

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors