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 services 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 (lets name it WebService11). TestComplete displays the WebServices editor, which is empty because we havent specified the tested web service yet. To specify the web service under test, press the Select button and use the ensuing wizard:
- Specify the location of the services WSDL document (this document holds the definition of the web service, its methods, helper interfaces, etc.)
- Press the Get Services button to retrieve the list of services defined in the specified WSDL document.
- Finally, choose the needed service and the SOAP protocol version that is used to transfer data between TestComplete and the tested service.
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 services methods:
As you can see, the tested service does not use any custom types and provides two methods:
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:
In general, the method call syntax is as follows:
In our case, the web service element name is WebService1 and the method name can be either
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:
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 Whats New in TestComplete 6.