This topic describes how to use Groovy script to run a test case from another project.
Where to use
There are two ways to run this script:
- As a Groovy Script test step.
- As a setup or teardown script on the project, test suite, or test case level in functional tests.
Example
Groovy
// Replace names of a project, test suite, and test case with those you need.
// Connect to the test case in another project.
def project = testRunner.getTestCase().getTestSuite().getProject().getWorkspace().getProjectByName("ProjectName")
def testSuite = project.getTestSuiteByName("Test Suite Name")
def testCase = testSuite.getTestCaseByName("Test Case Name")
// Run the test case.
runner = testCase.run(new com.eviware.soapui.support.types.StringToObjectMap(), false)
The getWorkspace
method works only when you run a test containing a script from the ReadyAPI user interface. When you run the test from command-line runners or on a LoadUI agent, the method returns null
.
See Also
Run Test Step From Another Project
Groovy Script Test Step
Groovy Scripting Samples
Scripting