# Auto Testing using UI

## **Add test data to the Policy**

Tests can be added to the Policy, when such a policy gets published then the added tests get embedded into the policy file.

Such tests are imported/exported together with their respective policies.

{% hint style="info" %}
**Note:** Tests can be run only when the policy is in the dry-run or demo status.
{% endhint %}

### 1. Adding Tests

Tests can be added to the policy via the corresponding menu option as shown on the screenshots below:

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-65e8602dc42608ce589f4a2a8a00cc1eca42770e%2F0%20(18).png?alt=media" alt=""><figcaption></figcaption></figure>

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-c3939135241b124b65934b5c764da92d879990a9%2F1%20\(20\).png?alt=media)

### 2. Running Tests

To launch a test navigate to the tests list using the ‘Test details’ menu option\\

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-7d69fd6c1361a26e7e98d8406eed5016e6e63bf8%2F2%20(22).png?alt=media" alt=""><figcaption></figcaption></figure>

\
Select the desired test in the grid and press ***Run (or Re-Run)***

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-8d9b816f4742283ed2c2e102cf913da0fe1de7dd%2F3%20\(19\).png?alt=media)

{% hint style="info" %}
**Note:** There could be only one active (running) test per policy, multiple policies can be running tests at the same time.
{% endhint %}

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-64d88b259ecdd962bcc5b5a420b29c5a13229610%2F4%20(17).png?alt=media" alt=""><figcaption></figcaption></figure>

### 3. View Test Results

Test results can be viewed in the test window

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-f41860dec2a3c270d56ff5b1f9f738e41b6e0446%2F5%20(20).png?alt=media" alt=""><figcaption></figcaption></figure>

There are potential outcomes of running policy tests

1. **Stopped** – test was stopped by the user
2. **Success** – test was successfully executed and the results are fully matching those originally captured

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-9698eef0a763712f7382e15efeb2c9ee08707686%2F6%20\(19\).png?alt=media)

3. **Failure (1)** – an error has occurred during the run of the test, the execution of the test was not completed

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-9ac143c582fa2eda2bffc3dc33761b836ff7ff7f%2F7%20\(19\).png?alt=media)

4. **Failure (2)** – test was executed, however test results (i.e. the produced artifacts) differ from those originally captured

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-0b60883a4d654f95c47e85b5dee588a349531d21%2F8%20\(20\).png?alt=media)

Detailed comparison of the execution results (documents) can be performed by clicking on the ‘Show more details’ button.

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-b7f8e26b5ad1ef2bf796dea3f9777a25fd197cd6%2F9%20\(17\).png?alt=media)

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-9b00f5e28d676a42b50f1e63d108fd489ca86069%2F10%20\(18\).png?alt=media)

### 4. Removing Tests

Tests which are not being run can be deleted.

![](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-87b628aaab976b028b93bc91f80a7c629dc8b1f2%2F11%20\(15\).png?alt=media)

### 5. Access from the grid

Tests can be managed and run from the Manage Policies grid.

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-516f473f86221a8433aeec05a2e160f5ba598f66%2F12%20(13).png?alt=media" alt=""><figcaption></figcaption></figure>

This view allows to:

* Add a test to the policies if it does not yet have any tests
* Run the most recently added test
* Re-run the most recently run test
* Monitor the status of the test being run

## 2. Demo Mode

To simplify the UI of policy testing (useful for novice users) a new ‘**Demo**’ mode of policy import has been introduced. In this mode all policy processing is ‘read-only’, policy editing is not possible, and no communication with external systems such as Hedera network and/or IPFS is performed. Policy execution in the **Demo** mode is similar to **dry-run**.

To use demo mode the corresponding option should be selected on the policy import dialogue.

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-0aa615d68b4ff30813846cad3f05962c03feb595%2F13%20(13).png?alt=media" alt=""><figcaption></figcaption></figure>
