Over a million developers have joined DZone.

Using Fitnesse for web service testing

Learn how API management supports better integration in Achieving Enterprise Agility with Microservices and API Management, brought to you in partnership with 3scale

Fitnesse is a proven and widely accepted acceptance testing framework. Due to the growing adoption of web services, the need for testing web services has become very important. There are lot of good tools out there to perform functional testing on webservices like SoapUI,SOAPSonar,etc. I have personally used SoapUI and its great for basic needs. A good functional testing tool should really help you in automating your tests.

Most of the tools out there have cool features to create test suites/test cases and write assertions. But over a period of time, when you have lot of web services, following are some of the common problems you might encounter with tools like SoapUI:

Refactoring: If the wsdl definition changes for some reason, how easy it is easy to refactor all the test cases/suites?

Simplicity: sometimes, xpath is not  sufficient to write a test case. SoapUI does support groovy scripts. But groovy is not something that can be used by all of your QA team members.

Sharing: When your entire QA team is actively involved in writing automated functional tests (eg: using SoapUI) how to share the same script between different team members becomes a concern. Its not so easy to merge xml files modified by different people for non-developers.

Readability: The readability of the test cases created is highly influenced by the element names in the wsdl file i.e you cannot take control of the naming convention of request parameters in your web service requests.

Most of the above said shortcomings can be overcome by using fitnesse for automating your webservice testing. Before, talking about the advantages lets take a simple example where i want to use yahoo web service to perform some search operation.

 


The above example uses yahoo api to make a search.The first table "Make Request to Yahoo" takes your search request and result size as parameter. The "Verify Response" table validates the actual response from yahoo search with your expected results. As you can see above,the tabular format of Fitnesse table is highly readable and easy to understand.

Going back to our above listed shortcomings in using tools like SoapUI, fitnesse addresses most of them like,

Refactoring: Since the fixtures are written in java, refactoring is easy.

Simplicity: QA team is not exposed to underlying comlpexity(fixture code). A simple tabular format looks more simple to them without worrying about any scripting language.

Sharing: This is one of the most appealing reason.Hosting as a wiki makes sharing so simple.

Readability: The column names in the Fitnesse table need not be same as the wsdl element names.You can have layer of absraction in the fixture code to take up this burden.

In this simple example no webservice frameworks have been used. The clients are created using HttpClient library and unmarshalling is done using JAXB.

For the complete source code of the above example, click here.

Unleash the power of your APIs with future-proof API management - Create your account and start your free trial today, brought to you in partnership with 3scale.

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}