Posted by: devakara on: September 4, 2008
Firstly one should have clear understanding of where the properties are going to be used before simply creating them in SOAP UI while developing Test Suites. That is while designing the test cases itself, one should categorize the properties on the basis of whether they are going to be used at the Test Case level or Test Suite level or above.
The primitve way is to simply add a “Properties” Step under any Test Case and load all the required properties in there.
To access such properties in Groovy script:
def props = new java.util.Properties();
props = testRunner.testCase.getTestStepByName(“Properties”);
def propValue = props.getPropertyValue(“PropertyName”);
Explicitly we should load the properties to some object and retrieve the value from there.
If we know that there are some properties which are going to be used at that Test Case level (that is with some/most of the test steps inside that TestCase) then its better to create the Properties at the corresponsding TestCase level. When we double click on any testcase in SOAP UI (2.0.2, and will not mention from now on, till any further update), we see window showing all testSteps under that TestCase, with some tabs below (Description, Properties, Setup Script, Teardown Script). Select the ‘Properties’ tab in there and upload the required properties which shall be used at that Test Case level.
To access these properties in Groovy script:
def propValue = testRunner.testCase.getPropertyValue(“PropertyName”)
This is very simple right, when compared to the previous approach.
In the same way, there might be some properties which could be used across the TestCases, then such properties deserve place in ‘Properties’ tab under the corresponding TestSuite window. Load the required properties there.
To access these properties in Groovy script:
def propValue = testRunner.testCase.testSuite.getPropertyValue(“PropertyName”)
In this way, we can maintain credibility of the code, and Suite becomes more modular.
GREAT JOB, … but… HOW TO make SAME thing but with setProperty. On diffrent levels (testStep – to – Project)
January 15, 2009 at 6:58 pm
Hi
I have a test suite with 10 test cases, each test case has between 1 to 5 test steps. All test steps need a session ID that is in the response of the first test step of the first test case.
Is there any way to tell the test suite to do all the steps
1- get session id
2- put session id in test steps
3- run all test steps
automatically, right now I do it manually.
January 16, 2009 at 11:04 pm
Hi Ehsan,
Initially create a property, say ’sessionIDProp’, at the TestSuite level.
Just after the first test step (of first TestCase) which yields the sessionID,
place a Groovy step to fetch that sessionID value and set to sessionIDProp
And thereafter, you could simply fetch the sessionIDProp value as needed for the
remaining TestCases using testRunner.testCase.testSuite.getPropertyValue(“sessionIDProp”).
Please get back if more help is needed.
Thanks
Devakara.