This topic describes the basic concepts of checking response data in LoadComplete tests.
Why Validating Response Data
To check whether the web server under test works correctly, LoadComplete compares received response codes against response codes specified in the scenario. If the codes are the same, LoadComplete considers that the requests were simulated successfully and the web server works correctly.
However, checking the response codes may be not enough to check whether the server works correctly. For instance:
The server may respond with the HTTP success code (200), but send data your test does not expect. A typical example is the Adobe Flash and Flex applications: they respond with code 200, but use AMF packets (the AMF protocol is at a higher level than HTTP) to send information on errors.
If your tested web server communicates with your client through a socket connection, messages the server sends are not HTTP responses and do not contain response codes.
To check whether your tested server responses correctly, use validation rules. Validation rules are comparison criteria that you add to scenarios in your tests and that compare the response data against expected values.
You can also create a validation rule if your tested server returns incorrect data (check the response data in the Response Body panel of the test log). After the issue is fixed, the validation rule will help you to check that the error does not occur anymore.
What Data You Can Check
Simple data types:
Complex data like objects or arrays.
To verify complex data, define an individual verification rule for each object property or array item.
|LoadComplete does not support validation of binary data.|
To learn what data (what response fields) you need to check, see your test plan or consult with your manager or developers.
Validation Rules in LoadComplete
To create validation rules:
On the Response page (for HTTP traffic) or on the WebSocket Message page (for WebSocket traffic), you specify rules for extracting data from a server response and saving it to a variable. See Extracting Data From Responses.
On the Validators tab of the response, you define validation rules that will be used to check the extracted values against the baseline values:
For step-by-step instructions, see Creating Validation Rules.
Validation rules are active during the scenario verification and during the test run. They work for all virtual users that simulate the scenario.
Validation rules you set for WebSocket server messages are active only if the server messages are enabled in the scenario (LoadComplete disables them by default). To learn how to enable WebSocket server messages, see Support for WebSocket Protocol (HTML5).
Every time LoadComplete receives a response, for which you create a validation rule, it compares the actual (extracted) data with the expected data. If the validation fails, LoadComplete will post an error message to the test log.
Depending on the test data you use, validation can pass for one virtual user and fail for another user.
If LoadComplete does not find a value to save to a variable, the validation fails.
You can find an example of creating a typical validation rule in Checking Whether a Server Response Contains Specific Text.