Forum Discussion
Unhandled
15 years agoContributor
The problem with your approach is that even if you do access the property, it is dynamic and your UUID will be different each time you read the value of the property.
Here is how you can access the property in your Script Assertion:
Instead you might want to replace your Properties test step with a Groovy test step (alternatively, use the Setup Script of the Test Case). In the Groovy script, generate your UUID and then store the UUID to a TestCase scope property. Each time your test case executes, a new UUID will be generated. Then future test steps may access this static test case level property.
Set property with Groovy Test Step/Setup Script
Use property in Test Request:
Get property in script assertion:
Here is how you can access the property in your Script Assertion:
log.info context.expand( '${Properties#correlationID}' )
Instead you might want to replace your Properties test step with a Groovy test step (alternatively, use the Setup Script of the Test Case). In the Groovy script, generate your UUID and then store the UUID to a TestCase scope property. Each time your test case executes, a new UUID will be generated. Then future test steps may access this static test case level property.
Set property with Groovy Test Step/Setup Script
myUUID = context.expand( '${=java.util.UUID.randomUUID()}' )
testRunner.testCase.setPropertyValue("correlationID", myUUID )
Use property in Test Request:
<CorrelationID>${#TestCase#correlationID}</CorrelationID>
Get property in script assertion:
log.info context.expand( '${#TestCase#correlationID}' )