I am using a groovy script within a Ready API test case to validate the results in a json web service response.
I want to use a variable (that is specified within a data source) to specify the json path that I want to validate, as this may change for each test run.
The following bit of code correctly assigns all the data referred to by the path results.address_components.long_name to the variable 'actualResponseOne'
def actualResponseOne = jsonSlurper.results.address_components.long_name.collect()
But, because within the same test I might want to validate different json elements ie. results.geometry.location_type for example I don't want to have the path hardcoded within the groovy script but instead set it up in a data source and assign it to a groovy variable within my script with ..
def testElementOne1 = context.expand( '${DataSource-Groovy-GoogleMaps#testElement1}' );
How to I refer to this json path within my code that assigns the data to 'actualResponseOne'? The below code doesn't work.
def actualResponseOne = jsonSlurper.${testElementOne}.collect()
Any help would be much appreciated.
regards,
Tam.