Access Properties

Applies to ReadyAPI 3.7, last modified on April 08, 2021

Groovy scripts have access to your project information, including properties, settings, and names of all items in the project. You can modify these from script to suit your needs during the test run, and then set them back to default values.

Where to use

There are several ways to run the scripts below:

Get and Set Properties

You can access all properties of ReadyAPI test items (projects, test suites, test cases, and so on) from your scripts in the following way:


// Get property from a test case
def testCaseProperty = testRunner.testCase.getPropertyValue( "MyProp" )

// Get property from a test suite
def testSuiteProperty = testRunner.testCase.testSuite.getPropertyValue( "MyProp" )

// Get a project property
def projectProperty = testRunner.testCase.testSuite.project.getPropertyValue( "MyProp" )

// Get a global property
def globalProperty = com.eviware.soapui.SoapUI.globalProperties.getPropertyValue( "MyProp" )

// In Script Assertions, you access test cases in a different way:
// def testCaseProperty = messageExchange.modelItem.testStep.testCase.getPropertyValue( "MyProp" )

// Set values to the same properties.
testRunner.testCase.setPropertyValue( "MyProp", 'someValue' )
testRunner.testCase.testSuite.setPropertyValue( "MyProp", 'someValue' )
testRunner.testCase.testSuite.project.setPropertyValue( "MyProp", 'someValue' )
com.eviware.soapui.SoapUI.globalProperties.setPropertyValue( "MyProp", 'someValue' )

Tip: Have a look at the TestPropertyHolder interface for digging into the object model.

Rename Test Items

Renaming test items such as projects, test suites, and test cases is a specific example of property change because the name of a test item is one of its properties. You can change it using scripts:


// Set names for the test case, test suite, and project = 'Sample Test Case Name' = 'Sample Test Suite Name' = 'Sample Project Name'

Some scripts may get items by their names. If you rename the item, those scripts will fail.

See Also

Data-Driven Testing Tutorials
DataSource Test Step

Highlight search results