If you are familiar with automation testing you might know the importance of dynamically storing or retrieving property values. In soapUI, we can story properties on different levels, say on project level, testSuite level and testCase level. Either we can hardcode the property even before the test run or we can create update and retrieve the property values dynamically using groovy script. Let us see how can we achieve this using groovy in soapUI.
The below sample groovy script will allow you to add, set and retrieve properties.
/*To make this for a test case level property, change the below line todef testSuite = context.testCase;
*/
def testSuite = context.testCase.testSuite;
def PropertyName = "UserName"
/*Below line checks if there is already a property named "UserName"*/
if(!testSuite.hasProperty(PropertyName))
testSuite.addProperty(PropertyName)
/*Below line of groovy code will set the value "user01" for the property*/
testSuite.setPropertyValue(PropertyName,'user01')
//Below line will retrieve the property value
def propertyValue = testSuite.getPropertyValue(PropertyName)