Validate a server response

Understand the context

Problems or errors occurring during the execution of a test scenario will bias your results, making them partially or -at worst- completely unusable. It is therefore fundamental to make sure that errors occurring during a scenario be clearly identified and traced. NeoLoad automatically identifies and reports HTTP-related errors or severe errors due to networking or application failures. However, NeoLoad cannot identify errors due to application logic, but provides a powerful validating mechanism that will let you locate unexpected or erroneous behavior. An application logic error can trigger chain reactions that could, in the end, cause an HTTP error: catching application errors as soon as they appear will make it much easier to understand and analyze the problem. The sooner an erroneous behavior is identified and traced, the quicker the resolution will be. Because NeoLoad provides mechanisms to validate application behavior, this technique can, to some extent, be used to achieve functional testing.

Finally, from a purely load testing point of view, it is also important to identify pages that are time costly. This section describes how to check that an HTTP response does not exceed a certain amount of time. This is consistent with non-functional requirements that are often expressed by users or clients and that you must ensure.

NeoLoad validations are expressed either for each HTTP request or for each Container or Virtual User. For more information, see Global Validation. The validation mechanism allows you to set conditions that must be met by the HTTP response to a specific HTTP request . NeoLoad provides three types of criteria by which validations can be expressed: time, content size and, lastly, the response content itself. This tutorial describes how these three criteria can be added and configured. It also shows you how to test your validations and where to configure NeoLoad behavior in the event the validation fails.

Add validations to an HTTP response

The example relies on the very simple HTML source code that follows

<HTML> 
<BODY> 
   <H1>Order references</H1> 
   <P> Thank you, your order has 
      been successfully submitted : 
      <B>#I45-020206-45RT347</B> 
   </P> 
<BODY> 
</HTML>

You may want your validation to apply to the contents of the HTTP response making sure that an order identifier has been correctly returned and also checking that the format of the order identifier is correct. The second validation will apply to a non-functional requirement: confirming and placing the order is a resource-greedy and time-consuming operation, you may want to make sure the response time does not exceed 2 seconds.

  1. Select the HTTP request for which the response will be validated:
  2. Open the Validation dialog:
  3. Test your validation. Erroneous or incorrectly-declared validations generate as many problems as no validations at all, so it is important to make sure validations are consistent. This isn't always easy, especially with complex scenarios. Most of the time though, a foolproof way to test your validations is to test the Virtual User containing the requests that have response validations. The following procedure describes how:
  4. Define NeoLoad behavior when assertions fail:
Related links

For more information about creating Virtual Users, see Virtual Users.

For more information about regular expressions, see Regular expressions.