tstmartin
14 years agoContributor
How to find the parent Test Case of a Run TestCase step?
I have a Groovy script (MyGroovyScript) in a common test case.
That test case is being used in other test cases using a Run TestCase test step.
I need to determine from within MyGroovyScript what test case is running the Run
TestCase step.
To clarify (I hope), outline of my project structure is below. When Suite1
TestCase1 is run, I need for MyGroovyScript to be able to determine that it is
the Suite1 TestCase1 test case that is running.
From within MyGroovyScript, testRunner.getTestCase() just tells me that it is
running in the COMMON_SUITE Login test case.
Thanks for any help!
-tom
MyProject
COMMON_SUITE
Login:
CL:step 1
CL:step 2
CL:step3:MyGroovyScript
Suite1
TestCase1
S1TC1:Step 1: Run COMMON:Login
S1TC1:Step 2: some request, with some properties set by S1TC1:Step1
S1TC1:Step 3: some request, with some properties set by S1TC1:Step1
etc...
TestCase2
S1TC2:Step 1: Run COMMON:Login
S1TC2:Step 2: some request
S1TC2:Step 3: some request
That test case is being used in other test cases using a Run TestCase test step.
I need to determine from within MyGroovyScript what test case is running the Run
TestCase step.
To clarify (I hope), outline of my project structure is below. When Suite1
TestCase1 is run, I need for MyGroovyScript to be able to determine that it is
the Suite1 TestCase1 test case that is running.
From within MyGroovyScript, testRunner.getTestCase() just tells me that it is
running in the COMMON_SUITE Login test case.
Thanks for any help!
-tom
MyProject
COMMON_SUITE
Login:
CL:step 1
CL:step 2
CL:step3:MyGroovyScript
Suite1
TestCase1
S1TC1:Step 1: Run COMMON:Login
S1TC1:Step 2: some request, with some properties set by S1TC1:Step1
S1TC1:Step 3: some request, with some properties set by S1TC1:Step1
etc...
TestCase2
S1TC2:Step 1: Run COMMON:Login
S1TC2:Step 2: some request
S1TC2:Step 3: some request
- Hi!
The context available in your groovy script should contain a property named "#CallingRunTestCaseStep#" holding the calling Run TestCase TestStep, so you should be able to do:
def calling = context.getProperty( "#CallingRunTestCaseStep#" )
if( calling != null )
{
log.info( "Being called by " + call.testCase )
...
}
Does that work ok for you?
regards!
/Ole
eviware.com