top of page

How to run a test step from groovy script

Step1: Add groovy script test step and enter the following code.


1. To run a test step from another test case:

def tCase = testRunner.testCase.testSuite.testCases("[OTHER_TEST_CASE_NAME]")
def tStep = tCase.testSteps("[OTHER_TEST_STEP_NAME]"), context)

2. To run a test step from another test suite:

def testStep = testRunner.testCase.testSuite.project.getTestSuiteByName("[OTHER_TEST_SUITE_NAME]").getTestCaseByName("[OTHER_TEST_CASE_NAME]").getTestStepByName("[OTHER_TEST_STEP_NAME]"), context)

3. To run a test step from same test case:

def step = testRunner.testCase.getTestStepByName("[OTHER_TEST_STEP_NAME]"), context)

In our example, we need to run the test step within the test case, so the code is as follows,

def step = testRunner.testCase.getTestStepByName("AddStep"), context)

In first line, we are defining a test step within the testCase, "AddStep" is the Name of SOAP request test step.

In Second line, we are running/executing the test step.

Step 2: Run the groovy script to see that the test mentioned in code is executed.

1,009 views0 comments

Recent Posts

See All

Minimum Deletions to Make Character Frequencies Unique

A string s is called good if there are no two different characters in s that have the same frequency. Given a string s, return the minimum number of characters you need to delete to make s good. The f

Smallest String With A Given Numeric Value

The numeric value of a lowercase character is defined as its position (1-indexed) in the alphabet, so the numeric value of a is 1, the numeric value of b is 2, the numeric value of c is 3, and so on.


bottom of page