top of page
Search
Writer's pictureCoding Camp

How to run a test step from groovy script



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


Syntax:


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]")
tStep.run(testRunner, 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]")
testStep.run(testRunner, context)

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

def step = testRunner.testCase.getTestStepByName("[OTHER_TEST_STEP_NAME]")
step.run(testRunner, 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")
step.run(testRunner, 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,245 views0 comments

Recent Posts

See All

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...

bottom of page