Forum Discussion

sanj's avatar
sanj
Super Contributor
7 years ago

what would I need to import in order to run test runner

I am trying to do the following but want it in a standalone groovy script. I already have the jars imported for READY API What packages do I need to import in order to run tests from groovy def...
  • aaronpliu's avatar
    7 years ago

    No need.

    Just pass a parameter (testRunner) in your method.

    // assumed that you put it in MyScript.groovy
    def myTest(testRunner){
        // something
        testRunner.testCase.testSteps["YourStepName"]
    }
    
    // call it in groovy step
    def t = new MyScript()
    t.myTest(testRunner)
    
    // if you defined a class MyScript.groovy
    class MyScript{
        def runner
        def myTest(YourStepName){
        // something
        runner.testCase.testSteps[YourStepName]
        }
    }
    
    // call it in groovy step
    def m = new MyScript(runner: testRunner)
    m.myTest(YourStepName)