Forum Discussion

krogold's avatar
krogold
Regular Contributor
7 years ago

How to get a run test case target's name ?

Hello, I use a lot of 'run test case' steps in my project and I would like to know if it's possible, in a quite straightforward way, to determine which test case is called by a 'run test case' step...
  • Radford's avatar
    7 years ago

    Place the following Groovy code into a Groovy Test Step within the test case that contains the "Run TestCase" test step, this will demo how to get the target test case name, and how it is different from the test case name.

     

    def runTestCaseStep = testRunner.getTestCase().getTestStepByName('Run TestCase Step Name')
    
    // Log the name of the calling run test case.
    log.info('Run TestCase Step Name = ' + runTestCaseStep.getName())
    
    // Log the name of the target test case being called.
    log.info('Target TestCase Step Name = ' + runTestCaseStep.getTargetTestCase().getName())

    Note: The "Run TestCase" test step is the class WsdlRunTestCaseTestStep.