How to test web services

How to test web services?

In the third part of Web Services testing tutorial, we are going to discuss – how to test web services? Web services are integral part of any enterprise application that makes testing of web services important. In this article, we are going to discuss the manual testing approach for web services.

(In Web services Testing Part I & Web services Testing Part II, we discussed about Web services and SOA fundamentals)

Web Services Testing

Web services testing poses slightly different challenges as compared to testing of a web application. There are no screens available and that makes manual testing of web services a little cumbersome as compared to other forms of testing. In this article, we are going to explain the manual testing approach for testing web services.

Web services can be used in a web application or a desktop application. A UI screen may use the web services to get values or perform some tasks asynchronously.

 How to test web services

Web services are part of a software development project and they are developed as independent units. Testing a web service independently will involve testing of functionality of the web service. This form of testing is very similar to functional testing of any screen. We can create the test cases comprising of test data and conditions.

Example

Let’s take an example web service to test it. W3 Schools provide some sample web services like Celsius to Fahrenheit conversion and vice versa. We have used CelsiusToFahrenheit web service for this article. When you click on this link, you will see the default interface of the web service, if web service is created correctly.

This page also shows the request and the response format. If you look at the request format, you can see the following section in the SOAP request:

<soap:Body>

<CelsiusToFahrenheit xmlns=”http://www.w3schools.com/xml/”>

<Celsius>string</Celsius>

</CelsiusToFahrenheit>

</soap:Body>

Preparing Test data for testing web service

There is just one input data required and that is <Celsius>. The web services interface, by default, presents this field to input the data and test it. To test this web service, lets create some test data. I am sure you must be remembering the formula for conversion:

T(°F) = T(°C) × 1.8 + 32

Using the above formula, we create the following test data and expected results. You can notice that I have used both positive and negative test data.

Test Data

(Temp in Celsius)

Expected Result Actual Result
0 32
10 50
-25 -13
100 212

Preparing Test cases for testing web service

Using the identified test data, we can prepare test cases for testing the web service with valid and invalid data. Some of the test cases are shown below:

How to test web services

To test the web service, simply enter the input values and click on “Invoke” button. You can see the result as shown below:

test-output

In the next part of this how to guide, we are going to discuss the automation testing approach for testing a web approach.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *