Functional Web Services Testing Made Easy with SoapUI - Part 1

Service-oriented architecture (SOA) and web services are becoming more and more popular in many development projects. In Java or .NET, exposing your business logic component as a web service is as simple as adding a few metadata annotations. Likewise, once you have a web service, you can use any client to consume it, right?

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.

Subtitle: 
Functional Web Services testing using SoapUI
Article Type: 
How-to
Article Resources: 
0
Average: 4.2 (5 votes)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Revathi_12 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

Do you mean Groovy API?

Revathi_12 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

I am not sure you can add multiple assertions in one click. My suggestion would be to use Groovy, parse the response and assert the results. It might be possible to do with the SoapUI Pro version, I have not used one though.

saritamohaptra 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: saritamohaptra

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.

 

bullparade replied on Fri, 2009/04/03 - 10:20am

Hello Meera, In SoapUI, is it possible to take a single request message, and create a test case that loops through a list of different data values and populates those data values into each new request? Using your NOAA wsdl for example; using the LatLonListZipCode request message, somehow loop this request with several thousand different zipcodes from an external file - how do we accomplish this? Sounds like it requires groovy? If this is the case, can you provide a snippet or example? Thanks!

mikey-B replied on Wed, 2009/04/08 - 1:15pm

Hi Meera - I am new to the SOA world with a lot to learn in order to be effective with SoapUI.  Thanks in advance for your contributions here.  It seems that what you are presenting is right in line with my initial needs.  Much to learn!  I have finished Part 1 - Where is Part II?  Did I miss link somewhere?

AnandKiran 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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.