# Assertions - Verify Response

When testing an API, it is usually not enough to verify that all our HTTP requests completed successfully. Often, it is necessary to make sure that we got the correct response from the server by examining the **response status, body or headers**.

With [Loadmill](https://www.loadmill.com), this is made easy by using **Assertions**. Assertions are used in conjunction with [parameters](https://docs.loadmill.com/test-editor/parameters) to do just that: examine the server's response and assert its correctness.

You may have an arbitrary number of assertions executed after each successful request. If an assertion fails, the next request will **not be executed** and the test scenario will be marked as **failed**, but the subsequent assertions for the current request **will be executed** nonetheless.

## Assertions editor

Assertions editor can be found in loadmill under each request cubical on it's expanded form.\\

<figure><img src="https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-be0898034abe83321823c587e402782f283dea31%2Fimage%20(66).png?alt=media" alt=""><figcaption><p>Assertion section in request editor</p></figcaption></figure>

Furthermore, there is an option to disable an assertion by clicking the three dots (![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-10b92e58a1a9fafe2f21da15855a599239eecc32%2Fimage.png?alt=media)) in the assertion line. A disabled assertion will still be evaluated, but it won't cause the test to fail.

<figure><img src="https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-6455925efc67d82c0e51d37b8fa503834e36376c%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-c76bf2cbd76028629cf3e441a24c2c99a5cdfa5e%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

## Assertions Creation from Response

It is also possible to create assertions directly from the response panel from the 'JSONPATH' window (only when the response is a JSON). After executing the test, click on one of the responses to expand it, which will open the response panel, as follows:

<figure><img src="https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-5596b3dbc498da0e49eabacc7bcafd500da89b73%2Fimage.jpg?alt=media" alt=""><figcaption></figcaption></figure>

Click on ![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-39781db25364cfb228c50c68448b4a28fab8b107%2Fimage.png?alt=media), then navigate to the desired parameter. For example, let's find the 'content-length':

<figure><img src="https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-178dea2d55993135330970b9f66c02a285f55187%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Now, simply click on the plus sign located in the top right corner, set the extraction, and add the desired assertion right from there!

<figure><img src="https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-7b49670f7f22fcc45381aed2bf27ce7a95ac887d%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

You can then see both the extraction and the assertion in the request editor panel:

<figure><img src="https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-3274fbfe4334da1ffaba1a3e3f342c15369b2f2d%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

## Assertion Types

The target of an assertion is always a parameter value. You may use built-in parameters, default parameters or any parameter extracted from the current or previous requests in the **current scenario** as the target.

![The request Assertions - Verify Response section](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-276c5a97eebe66395ccdb25546f3a23a303f882f%2FScreenshot%202023-03-21%20at%2015.12.24.png?alt=media)

When using assertions, it will usually require to use [extractions](https://docs.loadmill.com/test-editor/set-parameters-extractions) first to set the parameter with proper data and only then to attempt to validate it's form.

There are several types of assertions:

#### **Exists** - Validates that a parameter exists and not null.

* Example 1:\
  Assigning empty term to `param1` will result in assertion failure\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-82c3c53ca5e1ebedae336fd42975da17ef426cf0%2Fimage.png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-f425f5a992044519d26986750234bff21baafcbb%2Fimage.png?alt=media)
* Example 2:\
  Assigning any value to `param1` will result in passed assertion\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-549a43dcab5294ea135b9c8d5b21c490318bbe31%2Fimage.png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-540584b9efad037bfe1e456e495a2d7ed63d8a6e%2Fimage.png?alt=media)

#### **Doesn't exist** - Validates that a parameter doesn't exists or null.

* Example 1:\
  Assigning any value to `param1` will result in assertion failure\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-266bedbdb69067eb181edfc13bc08d066bc044e9%2Fimage%20\(80\).png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-e87339fb80f377ba469b8838f20e5160a48572f8%2Fimage.png?alt=media)
* Example 2:\
  Not setting `param1` entirely will result in passed assetion\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-fc9f4077ba6c0236df514bfa2211c433f265320e%2Fimage.png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-84b63f0052dbe61f84da828567d7054614b1ec1c%2Fimage.png?alt=media)

#### **Equals** - Validates that a parameter is equal to the given expression. The equality check is **case sensitive.**

* Example 1:\
  The assigned `param1` doesn't equals to loadmill hence will fail in assertion\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-ceef79c4d50bc84360286630f407f3a0866a3084%2Fimage.png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-7940a087d375afafda1a641de5cc475597e76671%2Fimage.png?alt=media)
* Example 2:\
  Extracting `$.args.app` json path field to `param1`(from the result that is not displayed) should be equal to "Demo" and will result the assertion to pass\
  Assigning numeric value to `param2` of 11.0 in postscript should be equal to "11", and the assertion will pass.\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-cdeaee4fb59c70627cd2c54a4371b79cdd7cabf3%2Fimage.png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-b1b42818860e3aa9965b218789638c332a95f6ae%2Fimage.png?alt=media)\
  \&#xNAN;***Note** that all values are implicitly compared as strings.*

#### **Doesn't equal** - Validates that a parameter is NOT equal to the given expression. The equality check is **case sensitive**.

* Example 1:\
  `param1` shouldn't be equals to 'demo' but it is, hence the assertion will fail\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-a50978f00180be284a9627a0d86981ea0d6ce0ff%2Fimage.png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-a4a471c67ca191f703b8f2acc52c5e7cbe344941%2Fimage.png?alt=media)
* Example 2:\
  `param1` doesn't equals to 'loadmill' hence the assertion will pass\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-f48cfe60911e5ba08d0721bce57796e9f7107dc8%2Fimage.png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-c7a40c96a2c30aebcdc44266670886348aaf2e05%2Fimage.png?alt=media)

#### **Contains** - Validates that a parameter contains a sub-string. The containment check is **case sensitive**.

* Example 1:\
  When `param1` set with the value 'loadmill-demo' and doesn't contains the string 'example' the assertion will fail.\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-8c6af9285d7cc57f93bd11848a41902488542e38%2Fimage.png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-b8401e60c3768b9150db38892278c15cfcac41db%2Fimage.png?alt=media)
* Example 2:\
  When `param1` set with the value 'loadmill-demo' and contains the string 'demo', the assertion will pass.\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-d39bdc725e1b91a6c4cb7a3ecd9c4c1ba58f4e9a%2Fimage.png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-512cc810ba4d2dd9feeb1cfe3aa7308e2eec9a59%2Fimage.png?alt=media)

#### **Doesn't contain** - Validates that a parameter DOESN'T contain the given expression. The containment check is **case sensitive**.

* Example 1:\
  When `param1` set with the value 'loadmill-demo' and contains the string 'demo', the assertion will fail.\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-c67327b05ae4ff6043a56c03537af9207da98477%2Fimage.png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-bc171d09d8d5524fa44b51d61e79d4475ad8790a%2Fimage.png?alt=media)
* Example 2:\
  When `param1` set with the value 'loadmill-demo' and doesn't contain the string 'example', the assertion will pass.\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-d7352442b2e7082c4809596cfd46140a376590a7%2Fimage.png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-9b9f96e96db653b8d44e10ab5cc41e5300379dfd%2Fimage.png?alt=media)

#### **Matches** - Validates that a parameter matches the given regular expression.

* Example 1:\
  The assigned epoch representation of the current time to `param1` will contain 13 digits would not match the regex (`^\d{10}$`), hence the assertion will fail\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-f897294ce4843c01b07a9da6dfd4c7e28b15ffe1%2Fimage.png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-375d0533c4f6520f16071edc612fd4dd1f9983ec%2Fimage.png?alt=media)
* Example 2:\
  The assigned epoch representation of the current time to `param1` will contain 13 digits and would match the regex (`^\d{13}$`), hence the assertion will pass\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-bb70c5eebb6a8c6de3e0c77dc54b2e8f18d9e368%2Fimage%20\(85\).png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-4cc211828abfb70831503590b0509b3ade572f62%2Fimage.png?alt=media)

#### **Greater than** - Validates that a parameter is greater than the given expression.

* Example 1:\
  `param1` is assigned with the value 31 that is not greater than 40 hence the assertion will fail.\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-888ed291fcd79dee89b80648076b75e1a7a4473c%2Fimage%20\(68\).png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-c51e66d3fbe9d3e89d43c71b380b420a8eac36f3%2Fimage%20\(81\).png?alt=media)
* Example 2:\
  `param1` is assigned with the value 31 which is greater than 30 will make the assertion to pass\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-41415feafcd542811131ff7b8b410357db558b92%2Fimage.png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-6acb9ee144146b80ea292c3e11b6556b171091a8%2Fimage.png?alt=media)

#### **Less than** - Validates that a parameter is less than the given expression.

* Example 1:\
  `param1` is assigned with the value 30 that is not less than 31 hence the assertion will fail.\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-9986b4d4a97e3ca67eaf306a45fd3eadbd8fc81f%2Fimage.png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-a60435ede58e8062d64af415cb038fdc0eece75e%2Fimage.png?alt=media)
* Example 2:\
  `param1` is assigned with the value 31 which is less than 40 will make the assertion to pass\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-c3da8d6f31f84750c537879e53d362b789908a4c%2Fimage.png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-34576600391f74146b97820d524bca78c3ac912c%2Fimage.png?alt=media)

#### **JSON Schema** - Validate that a parameter comply with given [JSON Schema](https://json-schema.org/).

* Example 1:\
  Given `param1` was set with a json as below, opposed to the expected schema the field "name" is not numeric hence the assertion will fail.\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-dd951380097da6dec1870cbab699816805765449%2Fimage.png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-d91f5932c0bfa2fa012059086385f725ad935701%2Fimage.png?alt=media)\
  Note, the assertion will suggests to exclude the failing field from the validation schema.
* Example 2:\
  Given `param1` was set with a json as below and the expected schema describes it correctly, the assertion will pass.\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-a0ea90c8db7ba3f0f75e5d661df1402f839e62ce%2Fimage.png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-be4588a9c3a8bde08ddd845098aa678b81b2e81b%2Fimage.png?alt=media)

{% hint style="info" %}
To prepare initial JSON schema out of a JSON you can search for 'from json to schema' in google or use a [tool like this](https://transform.tools/json-to-json-schema).
{% endhint %}

#### **JSON Contains -** Validates that a json contains a subset json, in such way dynamic fields can be omitted to avoid false negatives.

Accepting any value for individual field will accept "\*" notation\
Note, the subset json object should preserve the same hierarchal structure as the containing object while fields can be omitted.

* Example 1:\
  Given `param1` was set with a json as below, any mismatch\
  in a key or value on same hierarchy will result in assertion error:\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-681ac81a580f1bb87de0b38252a79cc096991643%2Fimage.png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-2b49fb3d893e18405cef25343d2ec8e687cee4a1%2Fimage.png?alt=media)\
  Note to the "Exclude ..." notations, clicking on them will adjust the value of the assertion to exclude the failing field.
* Example 2:\
  Given `param1` was set with a json as below, any partial subset in json-contains validation value with same structure will result pass in assertion:\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-a58685772b913301957e3007e84af43753708c13%2Fimage.png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-68fb06cf25ba5dd56d4f26692d09634983698c91%2Fimage.png?alt=media)\
  \- Using star notation to accept any value for `latitude` and `country` fields.\
  ![Click to enlarge the image](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-23cba29b131b2ec7285955a059d8972099657519%2Fimage.png?alt=media)\
  Note, the "\*" notation works only on simple values (strings/numerics/booleans)

#### **XML Contains -** Validates that an xml contains a subset xml, in such way dynamic fields can be omitted to avoid false negatives.

Accepting any value for individual field will accept "\*" notation\
Note, the subset xml object should preserve the same hierarchal structure as the containing object while fields can be omitted.

* Example 1:\
  Given `param1` was set with an xml as below, any mismatch\
  in a key or value on same hierarchy will result in assertion error: ![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-096a25e1ba4256f1e7d297fd07865162fe1f1d50%2Fimage.png?alt=media) <img src="https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-3f2fa688807885cfb2a0b3b6634d5bb7b4853e6b%2Fimage.png?alt=media" alt="" data-size="original">\\
* Example 2:\
  Given `param1` was set with an xml as below, any partial subset in xml-contains validation value with same structure will result pass in assertion:\
  ![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-d922229f1c359541008bbcb638b0c8be3f135ebd%2Fimage%20\(126\).png?alt=media)![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-2587c41d64629b8e69d04219b21923ae8145f208%2Fimage.png?alt=media)\
  \
  \- Using star notation to accept any value for `latitude` and `country` fields.\
  ![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-6ff5abb7ab178f8f2280c2f07eecc409396e76a0%2FScreenshot%202023-12-28%20at%2010.15.29.png?alt=media)\
  Note, the "\*" notation works only on simple values (strings/numerics/booleans)

You may embed parameters in any assertion expression. These parameters will be evaluated right before the assertion is executed.

See **an example of the assertion** that validates the generated ID is in [the format of UUID](https://docs.loadmill.com/api-testing/test-suite-editor/functions#__is_uuid-target) below:

![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-a6a316f911f3bebfd0474490002dc42981d191d0%2Fvideo1582528102-online-video-cut.gif?alt=media)

{% hint style="info" %}
:man\_mage: When creating tests via our [Chrome recorder extension](https://docs.loadmill.com/working-with-the-recorder), Loadmill will create **two automatic assertion types** for you:

1. Default assertions - for any extraction we find in the recorded test, we add a default assertion to it (example: "id" exists).
2. Specific assertions - for any parameter with given user key (for example, "success") we extract it and assign to it an assertion (example: "success" equals "true").

Optional automatic JSON Schema assertion: you can enable [this assertion](https://docs.loadmill.com/working-with-the-recorder/recorder-settings#strict-response-validation) within Settings - Recordings.
{% endhint %}

## Suggestions

In many cases Loadmill users use the same or similar extractions and assertions. We've implemented the Suggestions feature that allows team admins to configure a repository of [extractions](https://docs.loadmill.com/api-testing/test-suite-editor/set-parameters-extractions) and assertions within **Settings - Suggestions**.

Then, each user can add the assertions from the repository by clicking on **+ SUGGESTIONS**.

![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-a90b83e54bf83e432dd0b81603cbd4fc0e135e78%2FScreenshot%20-%202021-10-03T145350.482.png?alt=media)

By default, there are a few common extraction and assertion examples in the repository. Team admins can also navigate to the Suggestions Settings directly from within the suggestion dialog window.

![](https://684333474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHDbUNdi3wPd9vSolzU%2Fuploads%2Fgit-blob-fef884c7972cb893b4b41f8a251a9df6ea1f2648%2FScreen%20Shot%202021-05-09%20at%2015.40.18.png?alt=media)

## Caveats

Keep in mind that all parameter values are **textual**, i.e. a parameter has **no type** such as `Number` or `Array` that we know from common programming languages.

This is important in order to avoid confusion when using parameter extractors such as **JSONPath**. For example, consider the following scenario:

1. Extract the value for `books` via the JSONPath query `student.books` on

   ```javascript
    {
        "student": {
            "books": []
        }
    }
   ```
2. Assert `books` is **Not Empty**.

You may expect this assertion to fail but, in fact, it will succeed. This is because the parameter `books` is evaluated to `[]` and therefore is considered as a non-empty string. One possible way to correct this is to use a **RegExp** assertion on the `books` parameter instead: `\[[^\s]+\]`.
