WillJones
9 years agoNew Contributor
access numeric context property in groovy script
How do I access a numeric property I have set in the context. I have the properties set on the test case like this... testCrimeNo 12456W/02 testAddressId -2 I set a property in my test s...
- 9 years ago
Hi,
What you have done is not wrong, I can only really give tips on shorter syntax. Basically
1) Object properties e.g. Project, TestSuite, TestCase etc are only String properties
2) Whereas, the context map, can take any object type
So, perhaps just as a shorter version you could try
context["TEST_ADD_ID"]=Integer.parseInt(context.expand('${#TestCase#testAddressId}'))
Then
log.info context["TEST_ADD_ID"]
Note also:
context["TEST_ADD_ID"] is the same as context.TEST_ADD_ID
and
context.expand('${#TestCase#testAddressId}') is the same as testRunner.testCase.getPropertyValue("testAddressId")
Does this help?
Regards,
Rupert