Access Variables

Applies to ReadyAPI 3.5, last modified on January 19, 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 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

Since the test item name is one of the properties, you can change it in your 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