Negative testing of Web services
Relevant for: API testing only
When performing a functional test for your Web Service, you should approach the testing in a variety of ways. The most common type of testing is called Positive Testing—checking that the service does what it was designed to do.
In addition, you should perform Negative Testing, to confirm that the application did not perform a task that it was not designed to perform. In those cases, you need to verify that the application issued an appropriate error—a SOAP Fault.
To illustrate this, consider a form accepting input data—you apply positive testing to check that your Web Service has properly accepted the name and other input data. You apply negative testing to make sure that the application detects an invalid character, for example a letter character in a telephone number.
When your service sends requests to the server, the server responds in one of the following ways:
-
SOAP Result. A SOAP response to the request.
-
SOAP Fault. A response indicating that the SOAP request was invalid. Negative Testing applies only to SOAP faults.
-
HTTP Error. An HTTP error, such as Page Not Found, unrelated to Web Services.
UFT One can check for a standard SOAP result or a SOAP fault response. For example, if your Web Service attempts to access a Web page that cannot be found, it will issue a 404 HTTP error. Using negative testing you indicate that you expect a SOAP fault. In this case, the test run fails if the service accesses a valid Web page.
The Properties pane lets you provide values for the SOAP fault header and body. You can enter faultcode, faultstring, and faultactor values as well as custom properties using Any type parameters. Using the Checkpoint mechanism, you can validate these values and view the results in the run results.
For details on setting up the SOAP fault values, see SOAP Fault Tab (Properties Pane - API Testing).