Forum Discussion

divman's avatar
divman
Contributor
11 years ago

[Res]How to call & run test step from another project?

Hi,

I have two projects like below.

P1
---TS1
-----TC1
-------GScript 1

P2
---TS2
-----TC2
-------GScript 2

here i need to run a script in 'Gscript 2' which will need to call and run the 'Gscript 1'. i am using the below code and i get "java.lang.NullPointerException". could anyone help me how to achieve this?.

def step = testRunner.getTestCase().getTestSuite().getProject().getWorkspace().getProjectByName("P1").getTestSuiteByName("TS1").getTestCaseByName("TC1").getTestStepByName("GScript 1")
log.info step.name
testRunner.runTestStepByName(step.name)
  • Hi,

    I changed the script bit and i am able to get what i need. Here is the working code.

    def step = testRunner.testCase.testSuite.project.workspace.getProjectByName("P1")
    log.info step.name

    def runner = step.testSuites['TS1'].testCases['TC1'].testSteps["GScript 1"].run(testRunner, context)
    log.info ("runner status ....... : " + runner.getStatus())
  • This is not possible, I suggest that you create same step on the different project. Let me know if you have further questions.

    Regards,
    Temil
  • Sorry. i am not getting "I suggest that you create same step on the different project."!. i need to have a common scripts in one place. so i keep a project "P1" and i have a common script here. so from different projects if i need to call and run that logic, i can do so. is this possible?