TestComplete 6 Sneak Peek - Testing Web Services

Since TestComplete 6 is currently under development, the information contained in this article is not final and may change at any time.

Web services are a new generation of Web applications that use XML-based standards and protocols to exchange information. Unlike traditional client/server applications, web services do not have the graphical interface because they are not intended for human interaction. Rather, they provide programmatic interfaces that can be used to expose the service functionality in a client application, such as a Web page or an executable.

TestComplete 6, lets you perform functional testing of web services. You can create tests that call web service methods and check their response to determine whether the service works correctly.

Functional testing of web services is provided by a new WebServices project item and scripting object. The WebServices project item lets you manage a list of web services under test, explore the service’s methods and interfaces and create functional tests. This project item is available if the WebServices plug-in is installed and enabled. In order to configure the WebServices project item, you need the WebServices Editor plug-in. Note that both plug-ins are only available in the Enterprise edition of TestComplete:

Since TestComplete can record SOAP traffic (SOAP is the protocol used by web services to transmit data over a network), it is also possible to perform load testing of web services. You can do this the same way you perform load testing of web servers, by using the HTTP Load Testing project item.


In this article, we are going to test a sample web service that converts a Fahrenheit temperature value to a Celsius temperature value, and vice versa. We will create a simple functional test that checks if the conversion works correctly.

First, we start with creating a new test project with the WebServices project item and a WebServices element (let’s name it WebService11). TestComplete displays the WebServices editor, which is empty because we haven’t specified the tested web service yet. To specify the web service under test, press the Select button and use the ensuing wizard:

  1. Specify the location of the service’s WSDL document (this document holds the definition of the web service, its methods, helper interfaces, etc.)
  2. Press the Get Services button to retrieve the list of services defined in the specified WSDL document.
  3. Finally, choose the needed service and the SOAP protocol version that is used to transfer data between TestComplete and the tested service.

Click to enlarge

TestComplete updates the editor with information about the selected service, including a list of custom types defined in the WSDL document and a list of service’s methods:

Click to enlarge

As you can see, the tested service does not use any custom types and provides two methods: CelsiusToFahrenheit and FahrenheitToCelsius. Both of them take a parameter of the double type, and the return result is of the double type as well.

After we have explored the web service methods, we can create a sample functional test. We use the boiling temperature of water (which is 212 °F or 100 °C) in our example and we will see if the service can convert the value correctly. The test scenario is as follows:

  • Specify the tested temperature values.
  • Call the FahrenheitToCelcius method and pass the tested temperature value in Fahrenheit.
  • Compare the returned value with the expected temperature value in Celsius and log the result.
  • Call the CelciusToFahrenheit method and pass the tested temperature value in Celsius.
  • Compare the returned value with the expected temperature value in Fahrenheit and log the result.

To learn the syntax needed to call a web service method from scripts, you can select this method in the list and use the hint displayed above the list:

Click to enlarge

In general, the method call syntax is as follows:

WebServices.WebServiceName.MethodName(parameters)

In our case, the web service element name is WebService1 and the method name can be either CelsiusToFahrenheit or FahrenheitToCelsius.

Below is a script (JScript language) that implements the test scenario:





After running this script, we can see that the tested web service works fine and converts temperature values correctly:

Click to enlarge

With the upcoming TestComplete 6, you can perform testing of web services. TestComplete lets you explore web services, their methods and internals in the same way as you would explore applications in the Object Browser. In scripts, a few lines of code are enough to call a web service's method and verify its result.

Of course, the example we have in this article is simple, but we hope it will give you the basic idea behind creating web service tests in TestComplete 6. You can create more complex tests by incorporating other TestComplete testing capabilities into web service tests. For example, you can use the data-driven technique for a more thorough testing with a larger test coverage.




For a complete list of changes made to TestComplete, see What’s New in TestComplete 6.


Close

By submitting this form, you agree to our
Terms of Use and Privacy Policy

Thanks for Subscribing

Keep an eye on your inbox for more great content.

Continue Reading

Add a little SmartBear to your life

Stay on top of your Software game with the latest developer tips, best practices and news, delivered straight to your inbox