how to access a datasource result from calling groovy script
I've created a Groovy datasource that returns information in the results associative array available when the datasource script runs.
Now I want to run that datasource from another groovy script, but don't know how to access the datasource results information after calling the datasource. The datasource looks something like this:
def row = testRunner.testCase.testSteps["MyDataSource"].getCurrentRow() if (row < 100) { result["email"] = "user-" + String.format("%04d", row+1) + "@company.com" }
The calling script looks like this:
testRunner.testCase.testSteps["MyDataSource"].run(testRunner, context)
Is it possible to access the "email" key created by the data source step? I've tried a lot of methods, none of which worked.
Thanks!
Hi,
Each DataSource step has at least 1 property.
In order to reference that property you can use the syntax:
${DataSource#testProperty}
If you want to reference that property from a groovy script you need to use:
context.expand( '${DataSource#testProperty}' )
But I am not sure I understand your question... Normally I would use a datasource step in combination with a datasource-loop step.
So there will be an execution for each element in the datasource. Why would you call yours with another groovy script? What is the use case?