Forum Discussion
13 years ago
Hi,
here is one solution. its not very elegant, but seems to work well.
the first step of the test case is a datasource test step that reads the values of the message into parameters. It can be a grid, spreadsheet, whatever.
the second test step is a groovy script that reads the parameters and builds out the message and loads it to a test parameter in the next test step
(you can just right click in the groovy editor pane and select "get data" and it will build the line of code for you.
the third test step is the REST POST step. It has the test parameter that is loaded by the groovy script above.
test step 4 is the datasource loop step. loop to the groovy script.
Example of the getting a parameter value from a datasource
def identifier_key = context.expand( '${DataSourceCSV#identifier_key}' )
def identifier_system = context.expand( '${DataSourceCSV#identifier_system}' )
//build your message
def JSONMessage = '{"identifier":{"key":"' + identifier_key + '","system":"' + identifier_system + '"}"'
//load test parameter
testRunner.testCase.setPropertyValue( "JSONMessageProperty", JSONMessage )
hope this helps,
Philip
here is one solution. its not very elegant, but seems to work well.
the first step of the test case is a datasource test step that reads the values of the message into parameters. It can be a grid, spreadsheet, whatever.
the second test step is a groovy script that reads the parameters and builds out the message and loads it to a test parameter in the next test step
(you can just right click in the groovy editor pane and select "get data" and it will build the line of code for you.
the third test step is the REST POST step. It has the test parameter that is loaded by the groovy script above.
test step 4 is the datasource loop step. loop to the groovy script.
Example of the getting a parameter value from a datasource
def identifier_key = context.expand( '${DataSourceCSV#identifier_key}' )
def identifier_system = context.expand( '${DataSourceCSV#identifier_system}' )
//build your message
def JSONMessage = '{"identifier":{"key":"' + identifier_key + '","system":"' + identifier_system + '"}"'
//load test parameter
testRunner.testCase.setPropertyValue( "JSONMessageProperty", JSONMessage )
hope this helps,
Philip