Using multiple rows of a Data Source in a single TestRequest step
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2008
05:30 PM
03-03-2008
05:30 PM
Using multiple rows of a Data Source in a single TestRequest step
Does anyone know of a relatively simple way to consume multiple rows of a Datasource in one Test Request step?
The scenario here being able to combine multiple rows in a worksheet into a single batch request without "denormalizing" the worksheet data.
The scenario here being able to combine multiple rows in a worksheet into a single batch request without "denormalizing" the worksheet data.
5 REPLIES 5
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2008
11:26 PM
03-03-2008
11:26 PM
Hi,
there is no really easy way to do this currently; you will need to create a groovy script that manually builds the entire XML block by calling the next( testRunner, context ) method of the DataSource step to get the next row, something like
def xml = ...
def dataSource = testRunner.testCase.testSteps["DataSource"]
while( dataSource.next() )
{
xml += .. add to xml block..
}
context.blockOfXml = xml
and then use this variable with
${blockOfXml}
in your request..
Hope this helps!
regards,
/Ole
eviware.com
there is no really easy way to do this currently; you will need to create a groovy script that manually builds the entire XML block by calling the next( testRunner, context ) method of the DataSource step to get the next row, something like
def xml = ...
def dataSource = testRunner.testCase.testSteps["DataSource"]
while( dataSource.next() )
{
xml += .. add to xml block..
}
context.blockOfXml = xml
and then use this variable with
${blockOfXml}
in your request..
Hope this helps!
regards,
/Ole
eviware.com
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2008
06:45 AM
03-04-2008
06:45 AM
Thanks for the reply.
When I try 'dataSource.next' however I get the following:
groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.teststeps.WsdlDataSourceTestStep.next() is applicable for argument types: () values: {}
Do I need to cast dataSource to a different type?
When I try 'dataSource.next' however I get the following:
groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.teststeps.WsdlDataSourceTestStep.next() is applicable for argument types: () values: {}
Do I need to cast dataSource to a different type?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2008
06:48 AM
03-04-2008
06:48 AM
Hi!
sorry, my mistake.. the call should be
next( testRunner, context )
sorry, hope this helps!
regards,
/Ole
eviware.com
sorry, my mistake.. the call should be
next( testRunner, context )
sorry, hope this helps!
regards,
/Ole
eviware.com
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2008
11:56 AM
03-04-2008
11:56 AM
Thanks again.
I ended up turning the rows of data into XML in a Groovy step, but I assigned it to a property, then used property expansion to place the relevant data in the request (see below.)
What I should do is read the list of properties from the DataSource and build the XML generically.
Groovy script:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def dataSource = testRunner.testCase.testSteps['DataSource']
def xml = ''
while( dataSource.next( testRunner, context ) )
{
xml += ''
xml += '' + groovyUtils.expand('${DataSource#OrderID}') + ' '
xml += '' + groovyUtils.expand('${DataSource#OrderName}') + ' '
xml += ' '
}
xml += ''
groovyUtils.setPropertyValue("Properties","xml", xml)
Request fragment:
${Properties#xml#//dataRow[1]/OrderID/text()}
${Properties#xml#//dataRow[1]/Name/text()}
${Properties#xml#//dataRow[2]/OrderID/text()}
${Properties#xml#//dataRow[2]/Name/text()}
I ended up turning the rows of data into XML in a Groovy step, but I assigned it to a property, then used property expansion to place the relevant data in the request (see below.)
What I should do is read the list of properties from the DataSource and build the XML generically.
Groovy script:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def dataSource = testRunner.testCase.testSteps['DataSource']
def xml = ''
while( dataSource.next( testRunner, context ) )
{
xml += '
xml += '
xml += '
xml += '
}
xml += ''
groovyUtils.setPropertyValue("Properties","xml", xml)
Request fragment:
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2008
05:14 AM
03-05-2008
05:14 AM
Great!
Thanks for sharing your solution, this is not an unusual setup and I'm sure others will be able to use this..
regards,
/Ole
eviware.com
Thanks for sharing your solution, this is not an unusual setup and I'm sure others will be able to use this..
regards,
/Ole
eviware.com
