Ask a Question

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

SOLVED
sanj
Super Contributor

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 project = testRunner.testCase.testSuite.project
def testsuite= testRunner.testCase.testSuite
tc = testsuite.getTestCaseByName("Templates")
def testStep = tc.testSteps['24hr Test Template']
//def testStep = testRunner.testCase.testSteps['24HRRequestTest']
def status = testRunner.status
log.info("status : ${status}")

def result= testStep.run(testRunner,context).getStatus().toString()

 

1 ACCEPTED SOLUTION

Accepted Solutions
aaronpliu
Frequent Contributor

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

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)

View solution in original post

2 REPLIES 2
aaronpliu
Frequent Contributor

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

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)

View solution in original post

sanj
Super Contributor

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

So my guess is I do not have to do any includes in order to use the testrunner or context.

 

cancel
Showing results for 
Search instead for 
Did you mean: