Groovy in SOAP UI

properties at different levels in SOAP UI

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.

(Please feel free to get back if u have any trouble…as I’m just a mail away…leave a comment otherwise)

4 Responses to "properties at different levels in SOAP UI"

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.

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.

GREAT JOB, … but… HOW TO make SAME thing but with setProperty. On diffrent levels (testStep – to – Project)

Hi Corki,

If I understood your question correctly…to set such property (defined at TestSuite level)
in a Groovy Step of any TestCase (of that TestSuite) we need to write
testRunner.testCase.testSuite
.setPropertyValue(”sessionIDProp”,”propValue”)

Hope this helps!

Thanks,
Devakara

Leave a Reply