Using SoapUI for Web Service Testing

SoapUI is a great tool which can be used to test web services. In this post I'll show you how to set up SoapUI project for WS testing.

Create new project from File ->New SoapUI Project, and in "New Project Dialog" give name and the location of the WSDL file.


You can find the sample wsdl file I used for testing in github https://github.com/sandarenu/soapui-test.

Web Service Mocking

Service mocking is required when you are writing a web service clients and either you don't have the web service implemented or you don't have the access to the real service. Here's how to do that using SoapUI.

Create Mock of the web service by right clicking on the project and selecting 'Generate MockService'.

Once mock service is created you can mock the operations by clicking on the small icon in the service mock dialog.




Double click on the operation you just mocked and you'll get a dialog to configure mock responses.
You can configure any number of mock responses and then select how those response to be dispatched when our mock service receives WS request. There are many dispatching strategies available such as "Script", "Sequence", "Query Match", etc...

When you do some integration testing you need your mock service to respond based on different parameters of the requests you send. In such cases you can either use "Script" or "Query Match" dispatch mechanism.

Web Service Testing
We can use SoapUI to create test cases to test a Web Service we developed. To create a test suite right click on the project and select "New TestSuite" from the context menu. Then right click on the test suite we just created and select "New TestCase".



Once we have created the test case we can add test steps to it. Lets add a test step to test time for time zone 'lk'. Right click on the test steps dialog and select "Test Request" and create the request you want to test.
Once test request is created we can add assertion step to it. Click the "Assertions" button at the bottom of the test request editor.


Right click on the assertion editor and add "xPath Match"

 Put //Time as "xQuery Expression" and put value you are expecting as "Expected Result"

Now you can test this request using the Mock WS you created before. Start the mock service by clicking on the small green arrow found in the top of the "TimeServiceMock". Then open the test case you created above by double clicking it. Then run the test case again by clicking small green arrow in the to of the dialog box.


If every thing went well you'll be able get success result for your test case.

This is just the start. You can then add more test cases and assertions and improve your test suite. SoapUI site has good documentation on how to do functional testing. http://www.soapui.org/Getting-Started/functional-testing.html
You can refer that and get more information.

You can also find the SoapUI project for this example at https://github.com/sandarenu/soapui-test. Download it and open it using "File -> Import Project"

Happy Testing.....
 

Solving 'symbol lookup error' in new Eclipse 3.7 Indigo in Fedora

When I downloaded and run the latest eclipse 3.7 Indigo release, it crashed with a strange error.

symbol lookup error: /usr/lib/libwebkit-1.0.so.2: undefined symbol: soup_content_decoder_get_type

After some searching in the web I found out that it is due that I'm having an older version of libsoup library. I had libsoup-2.28.1-1.fc12.i686 in my fedora 12.
Issue was solved by updating that library using yum.
yum update libsoup