Jan 10, 2008

How to Test a Web Service

As a web service is something that has no user interface, we can’t interact with it without a special tool. That tool should allow composing XML requests via its own user interface. Commonly such user interfaces are text editors where you write your XML requests and controls for posting requests to the server.

Why not just unit tests?
Unit test is essential for every piece of program code. In many companies there is even a convention that code that did not pass unit test is not given for testing by quality control people. Unit test is simply part of development, not testing.
The minuses of considering passing unit tests enough acceptance criterion for a web service are:

  1. Unit tests are developed by a developer. Usually by the same person who has developed the application being tested. If a developer misunderstood a requirement or made a mistake in program code, many of his faults will be duplicated in the unit test.
  2. Classical unit tests are designed to test internal program code. But what is needed is to generate and run SOAP requests to web service methods. So if follow terminology that will be not unit tests but automated tests. And automated testing is activity carried out by testers, not developers.
One of the best tools (and the one I have experience with) is SoapUI by Eviware, and here are its advantages I used when testing a web service:
  1. Project structure. As in every well-established testing activity, I’ve started with test specification. The main part of a test specification is test cases divided into test areas. SoapUI allows structuring your test project into test suites (the same as test areas in my test specification) that contain test cases, which can contain test steps. This structure is well-managed in SoapUI – you can add, modify, delete and change order of every item in the structure.
  2. Test cases. SoapUI provides enough convenient tools to manage and run your test cases, and view SOAP responses to your test requests.
  3. You can perform Load Testing.
  4. Automation. But what if your web service contains too many methods with too many input and output parameters? It may take several days for each complete test of your web service if your tool does not provide functionality to automate your testing. SoapUI supports Groovy Script – a scripting language that is very similar to Java. I’d classify it as ‘light Java’. You can write scripts to access the database which is used and / or influenced by your web service. You can automate validation of your web service’s response against you input. You can automate the output of validation results into a file (which could be just a text file of HTML depending on your choice). And you can run an entire test suite with one click, which, combined with your validation and output automation scripts, allows you to perform entire test of your web service in minutes.

Free vs. Paid Version.
Paid version provides more convenience and is very good if you do not have experience in programming or scripting. For example, instead of finding out how to connect to a database in the free version, you can buy paid version which contains a special type of test step – "database connection". Read more at the product comparison page.

Summary.
Testing should be performed by somebody anyway it requires resources in any case. Of course project manager can assign developers who can write scripts similar to unit tests but testing not only internal methods in program code but making correct test requests via SOAP protocol. But since testers are responsible for testing why not use tool that does not require knowledge of complicated technologies like .NET? A tester who has some experience in programming can organize and perform test activities efficiently with help of SoapUI.

23 comments:

Anonymous said...

eclipse has a plugin to test web services as well - and it's free :)

Nikita Knysh said...

Hi Jay, thanks for your comment. SoapUI is opensource and free as well. They just propose extended funtionality for money but I believe free version is enough in most cases.

Stephane Wirtel said...

Yes, the free version of SoapUI is very good for a minimal web service. You can run a mock webservice based on the wsdl. You can modify the response and see the request. It's very fun to use it.

Sincerely I like it and I can tell you it's my favorite tool.

Nikita Knysh said...

Hi Stephane. Thanks for your comment. To tell the truth this is the only tool for testing web services I've even tried. But I've found that it's good enough to test medium-sized web services as well because of automation support.

SB Raghavendra said...

Hi Nikita,
Thanks for giving information on such good tool.Iam very new to Webservice.Could you please let me know where i need to start to learn more about SOAPUI
Regards,
SB Raghavendra

Nikita Knysh said...

Have you tried these links from the post?
http://www.soapui.org/
http://groovy.codehaus.org/

Good luck ;)

Anonymous said...

Hi!

I've a question about . How can I test several webs services at once, with soapUI tool?

Thanks it advance

Nikita Knysh said...

Hi :)

The best way is to have a separate project for each web service. You can manage all the projects within a single soapUI session.

Unknown said...

The link to wikipedia is bad. It links to Soap instead of SOAP.

Nikita Knysh said...

Thanks Ádám. Fixed.

Anonymous said...

I would like to create a Web Service with methods to other web services and be able to test them with soapui
Can I do it? how?
Thanks

Anonymous said...

Any idea about testing for RESTful webservices? will soapUI supports Restful services? for ex. GET, POST, PUT and DELETE methods?

Anonymous said...

hey, i was wondering, is testing a web service the same as calculating quality metrics on it??
by quality metrics i mean, availability, reliability, maintainability, etc.....

if not, do u know any software i can use to calculate quality metrics??

Anonymous said...

Have any of you used FitNesse for webservices testing. I understand it is an acceptance testing tool and runs on the FiT framework. But why not FitNesse for component based testing?

Nikita Knysh said...

Hi yega :)
I don't know anything about it.
Maybe you tell us why FitNesse?

Unknown said...

Hi Nikita,

I have been using SOAP UI tool for web services testing. It would be great if you can share your knowledge on how to integrate Quality Center (Test management tool) with Soap UI tool.

Thanks in advance ... :-)

Unknown said...

Hi Nikita,

Thanks for the detailed information. I have been using Soap UI for Webservices Testing and fould it's very good and easy to do also. Could you please share your knowledge on how to integrate Quality Center(A Test management tool) with Soap UI.

Thanks in advance ... :-)

Nikita Knysh said...

Hi Tarini :)

I haven't try to do that but if you use Quality Center you might want to use QTP to test web services as QTP and Qualty Center are from the same vendor :)

Unknown said...

hi nikita,
basically I am a testing guy with 6yrs exp. could you please let me know what prior knowledege is required for web service testing, I am new to this web service concept. let me know from where I have to start.

Thank you,
Srikanth

Farooq said...

Hello Patrick,
Please check out www.agiletestware.com

We have a plugin that synchronizes testcases and can export test results to Quality Center.
Your team can try the free demo after registering with the website.

Thanks

Farooq

Anonymous said...

Hello,
Please check out the first plugin for integration soapUI with HP Quality Center. The plugin allows you to sync test cases with Quality Center and also update test cases in QC. Some of the features are for this plugin are:
* windows installer for easy installation
* ability to export soapui request/response to QC
* ability to update test case name, test steps status
* soapUI Action (button on project level) to sync with Quality Center.

I would really appreciate if your team can register on the website and download the latest trail version of the plugin for testing the functionality. Comprehensive user guide with screen shots can be found on the website.

As always, your comments and suggestions are highly valuable. Please use the forums to suggest new features or bugs.

Sincerely

Farooq
www.agiletestware.com

Anonymous said...

So where is the example to setup to test the web service? This appears more to be hey soapui is available...good luck in setting it up

Anonymous said...

www.agiletestware.com
integrates soapui and quality center.