cancel
Showing results for 
Search instead for 
Did you mean: 

How to self-locate from inside a script step called from a different test case/test suite?

depstein
New Contributor

How to self-locate from inside a script step called from a different test case/test suite?

Hello,

 

I am running SoapUI Pro (1.9). The problem I am facing is this: I have a Groovy script step in one test case (call it StepA in CaseA, SuiteA) call another Groovy test step in a different test case within a different test suite (call it StepB in CaseB, SuiteB). How can I determine StepB's location from within the StepB script?

 

When I call StepB, I pass to it context and testRunner variables from StepA. If I query these objects from within StepB, all the methods and properties that return the current test step, test case or test suite give me StepA, CaseA and SuiteA respectively. I looked everywhere I could think of but I could not find any way of getting at StepB' own location (i.e. StepB, CaseB, SuiteB).

 

Is there any way I can get what I want? Or perhaps an alternative solution to what I am trying to do? I am developing a kind of shared library within my project. I have done this before with stand-alone scripts that instantiate a class and attach it to context. Such scripts can be used from anywhere within the project. But this time the script that I am calling requires data steps and other scripts within the same test case, which is why I need to be able to determine what that "same test case" is from within the script.

 

Thanks

Tags (3)
2 REPLIES 2
nmrao
Community Hero

Re: How to self-locate from inside a script step called from a different test case/test suite?

Little confused with above.

What is your use case?


Regards,
Rao.
depstein
New Contributor

Re: How to self-locate from inside a script step called from a different test case/test suite?

Rao,

 

Here is a simplified structure of my project:

 

Project

--SuiteA

----CaseA

------StepA

--SuiteB

----CaseB

------StepB

 

StepA and StepB are Groovy scripts, and they are located in different test cases inside different test suites within the same project.

 

With me so far?

 

I want to call StepB from StepA. I could do it like this:

 

def stepB = testRunner.testCase.testSuite.project.testSuites['SuiteB'].
testCases['CaseB'].testSteps['StepB']

stepB.run(testRunner, context)

 

So now I am inside StepB, and I want to get at its own test case (CaseB). If I do it like this:

 

testRunner.testCase

 

I will get CaseA instead. Why? because testRunner is the test runner that I passed to it from StepA. Same with context.

 

So my question is, is there a way for me to get at CaseB (or SuiteB) from inside StepB? Other than attaching it to context before I pass it to the script.

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors