Forum Discussion

Deduur's avatar
10 years ago

Pass property values to called test case

Hi,

I am a beginner in soapui testing. Hopefully you can help me solving this problem.
In my test project I have a test suites which contains several test cases. Multiple test case will start the same test case. To run this test case I need some property values to be transferred to this test case.

I tried to achieve this in two ways. But I failed in both.
1. I tried to call the test case and set the needed properties in the test case. I start the test case from a Groovy script. But I couldn’t find a good example how to set the properties in the called test case.
2. I tried to get the property values of the calling parent test case inside the called test case. It looks like the parent test case that called the test case isn’t available in the context of the running test case.

The test cases, that will call the same test case, will be run in parallel. So, I think it isn’t a solution to first set the property values and then start the test case, because they will be overwritten by the other test cases that run at the same time. Also using test suite properties for these values won’t work because of running the test cases in parallel.

My test project looks like this.
MyProject
TestSuite_APLtests
TestCase_user_01
Properties test step
Run_test <groovy script>
Step_01
…..
TestCase_user_02
Properties test step
Run_test <groovy script>
Step_01
…..
TestCase_General
Properties test step
POST sessions
Step_01
…..

The ‘Properties test step’ of each ‘TestCase_user_’ contains a user and password needed in test case ‘TestCase_General’ and will be different for each test case.
In the ‘Run_test’ groovy script of each ‘TestCase_user_’ the test case ‘TestCase_General’ is started by using:

def myTestSuite = testRunner.testCase.testSuite.project.getTestSuiteByName("TestSuite_APLtests ")
def myTestCase = myTestSuite.getTestCaseByName("TestCase_General")
myTestCase.run(null, false)

How can I add the properties user and password to the run comment that starts the test case?

If I try to get the property values with a groovy script in test case ‘TestCase_General’ I don’t know how to determine which test case has called ‘TestCase_General’. I found some posts on internet that suggests to use: context.getProperty("#CallingRunTestCaseStep#") to determine the calling test case. But this value is null. And when I try to check if the calling test case is available in the context by using: context.hasProperty("#CallingRunTestCaseStep#") this is false, so this doesn’t work to find the calling test case.

Can someone tell me what the solution will be to get this working.

Thanks,
Deduur
No RepliesBe the first to reply