Functional Web Services Testing Made Easy with SoapUI - Part 1
Before you make all your web services available to the public, however, you need to make sure they work. The only way to do this is by writing functional tests for your web services.
So much for the theory. I have seen very few projects that actually spend any time testing the web services they expose. In most cases, these web services are tested as part of the total system, using whatever user interface is provided. I myself was guilty of doing this before I discovered SoapUI.
From the day I discovered SoapUI almost 4 years back, however nothing stops me from writing functional tests for these web services. SoapUI makes it almost tempting to write tests using their GUI. You can create new test suites, add test cases, and add asserts to your test cases. This tool is easy to use; you don’t have to be a Java developer to write functional tests.
The tests you write in SoapUI are very manageable. I constantly hear developers saying, I have no clue what this test does; I didn’t write it.Tests need to be maintained just as your code does. Once you download and install SoapUI, you can have functional tests up and running in minutes. Can you write the same test in minutes without SoapUI? No way.
Developers too frequently write tests with no assert statements. Why even bother writing a test without asserts? With SoapUI you can easily add many types of assertions. You can add assert statements with the click of a button. If the ones within SoapUI aren’t sufficient for your requirements, I am going to show you how to use Groovy within SoapUI, which will make your testing even easier.
OK. You write you tests using SoapUI, add some asserts, and actually run them occasionally. This is better than nothing, but still largely pointless. Tests should be integrated with your build and should be able to be run with one click. Yes, I confess, I am the laziest developer you will ever see. Why bother doing the same thing over and over again when we can do the same thing with the click of a button?
If you have automated your builds and they are running as part of your Continuous Integration, of course, there even isn’t a single click to worry about (now that’s lazy!). SoapUI comes in handy here as well. You can run the test suites and all the test cases you created within it and above all you can fail the build just like you would when any other unit test fails. Cool, isn’t it? I’m excited, are you?
OK. Things are better. Now you have your tests, you have some groovy scripts, and it’s all integrated with CI. What use are your tests without reports? SoapUI comes to our rescue here as well. You can generate JUnit reports.
Let’s see how we can accomplish all this. In this article I am going to cover Functional Web Services testing using SoapUI, but don’t worry, there will be more articles on SoapUI and Groovy as well as on SoapUI and Continuous Integration in the coming weeks.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)




Comments
Revathi Premsekar replied on Fri, 2008/11/14 - 12:19am
How to integrate our own API with SoapUI?
Pls let me know ASAP
Meera Subbarao replied on Fri, 2008/11/14 - 12:30pm
Revathi Premsekar replied on Tue, 2008/11/18 - 1:55am
Hi meera I found the way to add our API with SoapUI.
Now I want to know how to add multiple Xpath match assertion in a single click? Because SoapUI allows us to add assertion one by one, if we need to compare 100's of parameters from actual and expected its very tedious.
Meera Subbarao replied on Tue, 2008/11/18 - 7:13am
sarita mohanty replied on Wed, 2009/01/21 - 3:59am
Hi Meera, I went through your replies, and it is really usefull , I understood well becasue I am working on SOAP UI currently.. but I am unable to open the attachments,
and I am really interested to know about the groovy scripts... being from non developent background I wanted to know how user friendy it is...want to now about the jmeter reports through SOPA ui,,,please send some user guide if you have....
Meera Subbarao replied on Wed, 2009/02/04 - 6:20pm
in response to:
sarita mohanty
If you know Java, you shouldn't have a problem using Groovy. On the other hand, if you are learning it for the first time. there are many Groovy books available. One such book is "Groovy in Action".
Let me know if you need anything else.
David Stuart replied on Fri, 2009/04/03 - 10:20am
Michael Bridges replied on Wed, 2009/04/08 - 1:15pm
Anand Kiran replied on Mon, 2009/04/13 - 3:42am
Hi Meera,
Do you haev any idea about how to run different test suites in a project with a single click using groovy .
Thanks
With Regards
Anand Kiran G
venkat neppalli replied on Wed, 2009/08/26 - 8:38am
Hi Meera,
UR ARTICLES ARE GOOD for practising SOA testing with SOAPUI tool.
I am working as Test Engineer, I want to learn SOA testing,Can you please send me information regarding Deployment of .WAR file in JBoss application server,
Currently i am using JDK1.4 and JBOSS4 softwares in my laptop,i placed .WAR file (which contain web services)in FOLLOWING PATH IE "C:\jboss-4.0.1sp1\server\default\deploy\HLRWebservices.War"
I tried to run Jboss server in command prompt ie C:\jboss-4.0.1sp1\server\default\deploy> RUN <Enter>
I opened IE and typed localhost:8080/HLRWebservices/Services-----I am getting HTTP 404 error,
can u please give me some more information how to deploy in Jboss and start services and see it in IE with above port number in my laptop.
PLEASE KINDLY HELP ME TO RUN WEB SERVICES
Todd Shoenfelt replied on Thu, 2009/10/15 - 12:12pm
First, great site!
SoapUI is an awesome tool. The GUI works great. But I'm not very good with Java and I'm having trouble executing test cases from the command line.
I do:
$> testrunner.sh -e <hostname> -r <name-project.xml> -c "Testcase"
After a long wait, I get:
================================
=
= SOAPUI_HOME = /home/todd/downloads/soapui-3.0.1
=
================================
soapUI 3.0.1 TestCase Runner
Configuring log4j from [/home/todd/eviware/soapUI-3.0.1/bin/soapui-log4j.xml]
Exception in thread "main" java.lang.NoClassDefFoundError: com.eviware.soapui.SoapUI
at java.lang.Class.initializeClass(libgcj.so.7rh)
at com.eviware.soapui.support.log.SoapUIAppender.append(SoapUIAppender.java:34)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:230)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:65)
at org.apache.log4j.Category.callAppenders(Category.java:203)
at org.apache.log4j.Category.forcedLog(Category.java:388)
at org.apache.log4j.Category.error(Category.java:302)
at com.eviware.soapui.tools.AbstractSoapUIRunner.runFromCommandLine(AbstractSoapUIRunner.java:80)
at com.eviware.soapui.tools.SoapUITestCaseRunner.main(SoapUITestCaseRunner.java:104)
Like I said, the GUI works fine. How do I fix this?
TIA,
Todd
radhakrishna th... replied on Sun, 2009/10/18 - 6:36am
Sandeep Koli replied on Fri, 2009/11/20 - 7:21am
Sandeep Koli replied on Fri, 2009/11/20 - 7:24am
Ravi Dasu replied on Wed, 2009/11/25 - 7:30am
Raghu Prasad replied on Wed, 2010/01/06 - 8:40am
Raghu Prasad replied on Wed, 2010/01/06 - 8:47am
Jose Campos replied on Thu, 2010/10/14 - 11:43am
Rajashree Prakash replied on Tue, 2011/04/26 - 6:38am
Hi Meera,
I have created around 93 REST requests under 6 Test Suites. When I run the Test suites, all the test cases are pointed to the same method name. So all the cases are failed since there is a mismatch between the assertions and the method.
How should i be able to set the method name for all the test cases individually.
Thanks and Regards,
Rajashree
K Burj replied on Fri, 2011/07/08 - 3:55pm
I can see that SOAP UI provides a way of doing your funtional quality testing. But it is a very cumbersome/tedius process when you have to make several hundreds of assertions for the data that is being returned in your response for a given test case. Not to mention manually enterring the XPATH Expressions ! And if you have several test suites each of which have several test cases and where the scenario happens to be that you are returning data that can cross reference one or more test suites then the process of asserting each xml element containing data is nightmarish ! Hope you get the picture that I'm talking about. I mean its great that you make a few assertions click some buttons and viola Soap UI handles it for you. But when we start talking about several hundreds of asserts for a test step soap request, then its not a happy camper situation.
My question is, and I am not sure if this is at all possible in Soap UI or for that matter any other FQT tool.
However is is possible to assert strictly at the xml entity level only without having to boil down to each element within a given xml entity. E.g. my response contains 3 entities i.e. House, Car, Boat each entity have 100 elements. Instead of asserting each element within those entities. Is is possible to declare assertion at the top most level of each entity and the rest can be handled by the tool?
Harish Behl replied on Thu, 2011/11/03 - 6:53am
in response to:
Meera Subbarao