Functional Web Services Testing Made Easy with SoapUI - Part 2 is live at the at Javalobby. Part 1 of this series helped provide the background needed to begin exploring web services testing. We learned the basics of SoapUI and how easy it was to write functional tests without writing a single line of code. We also saw how to add assertions to these tests. What we will examine now is how to use Groovy within SoapUI for test setup, test teardown, response validation, and much, much more.
Take a look at your leisure, as always give me a yell in case you need to find out more.
Tuesday, May 13, 2008
Subscribe to:
Post Comments (Atom)
Hi,
ReplyDeleteI can't find out anyone else who could give me an idea and resolve my simple issue...
I usually test my soapui project files with Ant and provide a ‘-e’ flag with testRunner.sh that I use in build.xml file.
I need to make a groovyScript Test Step in few of my test cases that are supposed to be run on different endpoint than defined in ‘-e’ flag.
Is there a way to enforce change of endpoint dynamically while my tests are running through Ant?
Can you please provide a groovyScript Code Snippet for the same solution.
Here is what I tried but didn’t worked:
def currentTestStep = testRunner.testCase.getTestCaseByName(”XxxTestStepName”);
currentTestStep.setEndPoint(”http://localhost/soapapp/appId=3″);
There is no such thing like testStep.setEndPoint(). Can please tell me how to go about it as I can’t figure this out in SoapUI API Docs.
I don't think there is any other way to change the endpoint other than the -e switch.
ReplyDeleteHowever, I would suggest reading the soapui project file, which is an XML file into memory, making the changes to the endpoint and saving it. These can be easily performed in Groovy as well.
Thanks for the reply... But I found out another simple way of using multiple endpoints through use of external properties file to soapui project file and then using property expansion within suite. All this, without using any '-e' flag with 'testRunner.sh' because I am having similar effect with property expansion within suite this time with multiple endpoints unlike 'testRunner.sh' '-e' flag.
ReplyDeleteHi,
ReplyDeleteI found you tutorial to be very help full.
Could you please give some example explaining how to perform Property transfer step with the help of groovy.
I mean to say transferring properties from step1 to step2 using groovy scripting instead of using Property transfer UI, because you have to manually set all the properties in that.
Thanks
Rajinder Singh
Hi Meera,
ReplyDeleteHello,
I’m new to Groovy and I’m using SoapUI to automate some test cases. I’m wondering if you may help me understand in detail how to make SoapUI interact with Groovy. I mean, I see examples of groovy for SoapUi but don’t seem to catch where to put them, if create them as Groovy scripts and then how do I call them inside a test case? If you can provide me to a link where I can see this, I’d really appreciate it.
Best regards and thanks in advance,
Igor (gorchis@yahoo.com)
Hi Meera,
ReplyDeleteI’m new to Groovy and I’m using SoapUI to automate some test cases. I’m wondering if you may help me understand in detail how to make SoapUI interact with Groovy. I mean, I see examples of groovy for SoapUi but don’t seem to catch where to put them, if create them as Groovy scripts and then how do I call them inside a test case? If you can provide me to a link where I can see this, I’d really appreciate it.
Best regards and thanks in advance,
Igor (igorcarreon@gmail.com)
Hi,
ReplyDeleteI would like to know how could we do multiple runs for the same request…
For example if i want to do multiple runs for a add webservice
a =1
b =2 one run
a = 3
b=4 sec run
a =5
b =2 third run……..
So how we achieve this by SOAPUI
Hi,
ReplyDeleteHope your doing well. I have a doubt in SOAPUI.
I would like to know how could we do multiple runs for the same request…
For example if i want to do multiple runs for a add webservice
a =1
b =2 one run
a = 3
b=4 sec run
a =5
b =2 third run……..
So how we achieve this by SOAPUI
Try using a Groovy script and loop through all your different values.
ReplyDeleteIf you want to change endpoint dynamically. Please use the syntax below
ReplyDeletedef url = "your url"
testRunner.testCase.getTestStepByName("XXXX").getTestRequest().setEndpoint(url)
-Vivek Biswas
hi,
ReplyDeletei am having a simple issue which am not able to resolve.
i'm writing groovy script inside the on Request script of my mock service. now i want to execute one method that is present my java program. one more thing is i don't want to install groovy in eclipse. can u plz tel me how to code it.
thanks in advance.
You will have to install Groovy to get it working.
ReplyDeletedef userData = new XmlSlurper().parseText(mockRequest.requestContent)
ReplyDeletewith this command am getting the xml. now i want to get a specific node value say 'name' from that xml. how can i code that.
thanks in advance
Thank you for posting this column. It was absolutely wonderful. The documentation on this blog is far and away better than that on the SoapUI homepage, and it was written almost two years ago!
ReplyDelete-A very appreciative Developer
Has any one done done this? soapUI integration with seleniumRC
ReplyDeleteHi meera ,
ReplyDeleteI am new to web service and SOAPUI . is it possible to generate the soapui-project.xml from WSDL using groovy script ?
You should be able to do so. I haven't done that though.
ReplyDeleteWsdlProject project = new WsdlProject();
ReplyDeleteWsdlInterface[] Wsdls = WsdlImporter.importWsdl(project,"D:\\Projects\\ShoppingService.wsdl");
above are the sample which i am trying to get the ShoppingService.wsdl to xml .can you help , how to save this buffered data in file.
Thanks in advance
Warm Regards,
Jagadeesan
Hi Meera,
ReplyDeleteNow i can able to generate the project XML's. But i wanted to configure proxy settings via groovy script engine . Please can you help me out to resolve this issue.
Thanks in advance
Warm Regards,
Jagadeesan.M
Hi Meera,
ReplyDeleteI'm new to SoapUI and want to wrtie script in Groovy. DO I need to install anything else to get started with groovy. I work on SoapUi 3.6.2 Pro version
I don't think so, it is available by default.However, I haven't used the Pro version.
ReplyDeleteHI Meera,
ReplyDeleteI Want to save the request and response xml as a xml file at the local . how can this be done writing groovy scripting.Please suggest me
Thanks,
Anil
Hi Meera,
ReplyDeleteAm working on SOAPUI.I Want to save the Request and Response XML as xml files and save it to my local machine.I need some groovy script to do this. Please suggest and help me.
Thanks,
Anil
Hi Meera,
ReplyDeleteI'm new to SOAP UI an Java World.
We are using SOUP UI to test java restfull services and Jboss application server.
Everything was fine when we were using Jboss basic authentication.
We moved recently to Jboss form based authentication.
All my call are failing now for authentication. All the call are returning login page content as Response.
How do we use SOUPUI and restfull services with form based authentication.
Any help would be greatly appreciated.
Raj
I have to do performance test, I wish to change Load Test Strategy but I can't find way to do it.
ReplyDeleteFor example:
time [seconds] - activity
0 - start test
5 - 10 of users are sending request
10 - 20 of users are sending request
Could You help me to do it?
--
Greg.
Great blog! Anyone know how to get the endpoint that was used from the -e parameter passed from the commandline when using testrunner?
ReplyDeleteHi all,
ReplyDeleteI want to save the request xml received by mock service to some file on my local machine. Please share your ideas.
Thanks.
Hi all,
ReplyDeleteI want my mock service to validate the received request xml against schema(.xsd). Any idea how to implement this?
I was thinking about groovy script. But there I am not able to extract the body part of received xml.
Please suggest and help.
Many thanks in advance.
Hi Meera,
ReplyDeleteHow can I feed a response of one request to another in SOAP UI through Groovy Scripting ?
Thanks in advance!
Hi Meera,
ReplyDeleteI am testing REST API services written in Java servlets in SOAPUI,they are not web services but using http/xml communication. I would like to test the output of one parameter of one api to another api service as input. Could you please let me know how do i design this in test suite and where to use groovy script
Hi Meera,
ReplyDeleteI am new to the soapui tool user,can you please suggest how to start the performence test using this tool.thank in advance any helpful links or blogs
Hi Meera,
ReplyDeletei am new to soap-ui.We have soap-ui installed in our client machines. From our development team we got the end point and some wsdls. I dont have any idea how to use this. What are all the configuration changes i need to do in soap-ui.
Before the VPN was configure we used to give C32 documents to the dev team to load into the system manually, but they suddenly came up with the soap-ui.
please help me.
You can contact me :
sanjeev.b.singh@accenture.com
ph no:07411407947 (Banglore)
Hi,
ReplyDeleteI have an issue that i have been looking at for a while- couldnt find a suitable solution on the web. Is there a way I could send a hard-coded SOAP request(XML) form to SOAP UI at run-time?
I do not want to use SOAP UI form feature to fill in the details. I already have the SOAP request in XML format with all the details filled in. I want to find a way to save this request in a text file, and have SOAP UI read this text file, use the data as the request. I dont mind if i have to do this by groovy script either.. Please respond at the earliest.
Hi Meera,
ReplyDeleteIs it possible to include an OR operator in groovy script?I am completely new to this groovy.
ex:-i mean i need to check whether the response message has either this A OR B..how can i do that?
Just like Java, use | or || operator.
DeleteHi Meera,
ReplyDeleteGood post! Now pls answer my question..
My Question: I need to pass a script's value as a part of a Request's endpoint. How to perform this?
Scenario: I should maintain a id throughout the test suite which contains 10 or more Test cases. The ID which I get on executing the first Test case, should be passed as a part of the endpoint for the next coming test cases, say wwww.google.com/{id}
I tried: Creating the test suite and test cases, then adding HTTP Test request test step for each test cases. And then, after the test case has finished executing, the response is written to a xml file by using a Groovy script as a test step. BTW both the request and response are in JSON format not in XML. After writing the response to a file, I use another script to read the response from the file, and parse the JSON content to get only the value I need. Then I added the parameter to the endpoint for the next Test step, say www.google.com/$id. However, this failed!
Now,how to pass this value as a part of the next test step's endpoint? Please guide me on this
I haven't used SoapUI/Groovy with JSON.
DeleteFor this, I think you would be better off using JsonSlurper to parse the response of your HTTP step. Then you can use dot notation to get to the specific node with the data you want to pass into the next test step.
DeleteWould look something like this:
import groovy.json.JsonSlurper;
def response=context.testCase.testSteps["YourTestStepName"].testRequest.response.responseContent;
//log.info("Response: " + response);
def slurper = new JsonSlurper();
def json = slurper.parseText response;
log.info("json: " + json);
def htmlNode= json.html;
Hi Meera,
ReplyDeleteHow to use project properties in groovy script?
i used ${#Project#propertyname} but not works...
Plz help
Hi,
DeleteMake sure you have property in project level as you these in Project navigator and you can see two tabs in below section there you have to select custom properties and then add your property and property value, then you can use this property thorught the project as,
just right click on the Groovy script editor and in field select Get Data-> Your Project -> then which property data you want just select that. now you can use this for all the property in the in your project.
for more details visit or post your qury on
http://lgsofttest.blogspot.in/
Hi,
DeleteMake sure you have property in project level as you these in Project navigator and you can see two tabs in below section there you have to select custom properties and then add your property and property value, then you can use this property thorught the project as,
just right click on the Groovy script editor and in field select Get Data-> Your Project -> then which property data you want just select that. now you can use this for all the property in the in your project.
for more details visit or post your qury on
http://lgsofttest.blogspot.in/
To learn soap Ui very easily go through this site ……
ReplyDeleteThis helped me a lot to learn soap ui basics to advance
http://www.simplecodestuffs.com/soapui-tutorial/
Hi Mera,
ReplyDeleteI need help on to add multiple xml nodes in the request based on the data source. As you see as below,
I have product that I want to verify the price of products by state and location. State can have only one product or multiple products. Based on this scenario, I would like to add Product Detail xml node based on the data source.
Here is sample file that I have created.
VA
${DataSource#P_Location}
${DataSource#P_Name}
${DataSource#P_ProductDetail}
Data set in excel
State Location ProductName ProductDetail Prices
VA Arlington Apple IPhone4 600
Reston Apple Iphone5 700
MA Fairfax Apple IPhone4 600
MD Gaithersburg Apple Iphone4 500
Gaithersburg Apple Iphone5 600
Gaithersburg Apple IPod 495
GA Chantilly Apple IPhone4 300
Please let me know
Hello,
ReplyDeleteI am just wondering how I can create a new test step with a soap request in SoapUI using groovy?
Thanks in advance!!
Hi Meera,
ReplyDeleteI observed the below steps as the first steps in most of the groovy scripts.
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(testRunner)
My question is: Whats exactly mean by context and testrunner in the above steps?
What are the differences between context and testrunner?
In what situations, context and testrunner can be used in the groovy script?
Many thanks in advance....
Hi,
ReplyDeleteI am new to SoapUI, I am using SoapUI 4.6, and I have created a RestService.
I have parameterized my URL parameteres like : ( url:port/{api}/{customers}/{id}/{storedPaymentCards}
Now I need to execeute a case where I need to pass a blank id, so that my request would be like : (url:port/api/customers//storedPaymentCard)
This request is working fine in POSTMAN REST client but it is not getting executing in SOAP UI.
Please Let me know where is the issue and where I am wrong , I am eagerly waiting for early response. ??? My email id is : jain.raksh25@gmail.com
Thanks and regards
Rakshit