0% found this document useful (0 votes)
30 views4 pages

How To Get Details of Any Type of Test Steps To A Groovyscript Test Step

Uploaded by

Gunreddy Ram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views4 pages

How To Get Details of Any Type of Test Steps To A Groovyscript Test Step

Uploaded by

Gunreddy Ram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

How to get Details of any type of test steps to a Groovyscript test

step - SOAP UI Pro


In SOAP UI there is something called Groovyscript. This is a very powerful test step available in
the SOAP UI test suite . We can do a multitude of things with Groovyscript. It is simple , easy and
once you understand it is a very powerful and flexible tools. Somethings it can do things which
was otherwise thought to be impossible

By default if you are using the SOAP UI Pro , you get the following option through which you can
very easily import data from any test step. Once you create a Groovyscript test step like below ,
by right clicking on the test suite / test case of SOAP UI

Once you are in the Groovyscript editor - You can just right click(your mouse ofcourse ) and you
will the the option to Get Data as seen below
As you can see, If you are using SOAP UI pro , You can get all the properties that you stored in
each Global level, Test Suite level, Test case level can all be accessed . But the issue is that
only those elements which you store as properties can be retrieved using get data . So if I
choose one particular value - Eg. LogRequestResponse

The corresponding code will be generated as follows

def logRequestResponse = context.expand( '${LogRequestResponse}' )

If I choose one property from Test suite level the code will look like this

def requestFile = context.expand( '${#TestSuite#RequestFile}' )

If I choose property from Test Case level the code will have to look like this

def findPartyContacts_Shpr_time = context.expand( '$


{#TestCase#FindPartyContacts_Shpr_time}' )

As I said , Only those property that you set manually or through script can be accessed like this .
If you want to capture some runtime value , like status of assertion . You cant use the get data .
Now here is where the following groovyscript code might be useful to you . 

First step is to get all the test requests in a particular SOAP UI test case into an object . 

Here I am going to store all the test step of the Test case into an object called requests 

def requests = testRunner.testCase.getTestSteps()

When I do a log.info for requests like follows 

log.info requests 

Following information will be available in the Logging pane 


Wed Jun 12 11:40:15 IST 2013:INFO:
{FindPartyAddress_Cnsgn=com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep@9e3
a2]

Now that all the test steps are available to us, We can call different methods of the object to get
whatever information that we want.

One simple and very useful effective method is the .name method or getLabel() method. In order
to do that we need to retrieve the selective type of test step . In SOAP UI there are several test
step types such as 

Suppose you want to get all the SOAP Test requests into one object you can do that using the
following code .

From the previous code we know that the groovy class type for the SOAP Test request
is com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep

Now we can retrieve all the SOAP test request from the Test case using the following code 
def SOAPrequests =
testRunner.testCase.getTestStepsOfType( com.eviware.soapui.impl.wsdl.teststeps.WsdlTestReq
uestStep.class )

I can get the requests name using the following code 

def SOAPrequests =
testRunner.testCase.getTestStepsOfType( com.eviware.soapui.impl.wsdl.teststeps.WsdlTestReq
uestStep.class )
def requestsName = SOAPrequests.name

If I do a log.info for reqeustsName , I can get all the name of the SOAP test requests like follows

Wed Jun 12 12:01:46 IST 2013:INFO:[FindPartyContacts_Shpr, FindPartyAddress_Shpr,


FindPartyAddress_Cnsgn, FindPartyContacts_Cnsgn, CreateShipmentRequest,
AddChargesShipment, ReleaseCharges, Backup of [ReleaseCharges]]

This is an java class array type . So you can do a groovy loop to perform any operation for all the
elements in the array 

For the array requestsName , Elements of the array can be accessed based on the numeric
index of the elements. 

For eg - requestsName[1] will give the first test step which is - FindPartyContacts_Shpr

You can then get various associated information using the different methods 

Firstup you need to get the Test step object for the name using the code 
 def testStepObj= testRunner.getTestCase().getTestStepByName("FindPartyContacts_Shpr")

Then you can get assertions of the test step 

def AssertionListStatus = testStepObj.getAssertionList().status

So if you have around 10 different assertion in your test step - FindPartyContacts_Shpr, You can
get the status of all these assertions, If they are pass or fail using this technique. This can be
further used to either set any property or to write it to any file using data sink . 
Posted 12th June 2013 by Sureshkumar

You might also like