Interview Questions

How to Get and Set properties ?

SoapUI FAQ


(Continued from previous question...)

How to Get and Set properties ?

Getting properties from groovy is straight-forward; all objects that contain properties have a getPropertyValue / setPropertyValue methods. The following examples are from inside a Groovy Script step:

01.// get properties from testCase, testSuite and project
02.def testCaseProperty = testRunner.testCase.getPropertyValue( "MyProp" )
03.def testSuiteProperty = testRunner.testCase.testSuite.getPropertyValue( "MyProp" )
04.def projectProperty = testRunner.testCase.testSuite.project.getPropertyValue( "MyProp" )
05.def globalProperty = com.eviware.soapui.SoapUI.globalProperties.getPropertyValue( "MyProp" )
06.
07.// setting values is equally straigh forward
08.testRunner.testCase.setPropertyValue( "MyProp", someValue )
09.testRunner.testCase.testSuite.setPropertyValue( "MyProp", someValue )
10.testRunner.testCase.testSuite.project.setPropertyValue( "MyProp", someValue )
11.com.eviware.soapui.SoapUI.globalProperties.setPropertyValue( "MyProp", someValue )

(Continued on next question...)

Other Interview Questions