Validations

Last modified on October 8, 2020.

You add validations to your API test to examine responses of the tested web service and to check if it works as expected.

Validations are also known as checkpoints or assertions. They are an essential part of load testing. The errors that a heavy load might cause don’t necessarily mean the tested service crashed or a connection to it is lost. The service can start responding slower than your clients expect, or it can return only part of the requested data or skip some requests, and so on. Validations help you evaluate server responses and detect malfunctions.

Add a validation

You create validations when you are creating a new API test or editing the existing one:

  1. In the API test editor, select Add > Validations from the menu in the top left corner:

    Add > Validation menu item

    – or –

    If you already have validations in your test, the editor displays the # validation(s) button in the top left corner. Click this button:

    API Test editor - Validations button

    This will open the Validations dialog:

    Validations dialog box
  2. In the dialog, select the desired validation from the Validation Type drop-down list:

    Select validation type
  3. In the subsequent dialog:

    • Specify the validation name. It should be unique within the test.

    • Select the requests (or test steps) to which the validation will apply.

    • Specify the validation conditions. These depend on the validation type you selected. See below for details. Here is an example of the SLA validation settings:

      SLA validation parameters

    Click Add Validation when you are done.

Check if the validation works

To check how the validation works, simply run the request or the entire test. LoadNinja will inform you if the validation fails:

The Run test button

What happens if the validation fails?

If the validation fails, LoadNinja stops running the API test (that is, it stops simulating the virtual user) and logs an error.

Validation description

Validation Description
Status code

Checks if the response status code equals or doesn’t equal the specified code. If needed, you can check for multiple status codes. Use commands to separate them.

SLA

Checks if the response to the request arrives within the specified number of seconds.

Simple Text

Checks if the response contains or doesn’t contain the specified text string.

Edit a validation

  1. In the API test editor, click # validation(s) at the top left corner:

    API Test editor - Validations button
  2. In the subsequent dialog, find the needed validation and click next to it:

    Edit validation

    Click the image to enlarge it.

  3. Configure settings in the subsequent dialog.

    Click Edit Validations to save the changes.

    To discard the changes you have done, simply close the dialog or click Back.

Delete a validation

  1. Click # validation(s) on the top left corner of the test editor.

  2. In the subsequent dialog, find the validation you want to delete and click next to it:

    Delete a validation

See Also

UI Tests (or Scripts)
UI Test Recorder

Highlight search results