# JSON Test File

## **Test collection**

### Parameters

| **Parameter**    | Type                                            | Description                                                                                      |
| ---------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| `processName`    | String                                          | Name of the process for which you want to run a test                                             |
| `processVersion` | Int                                             | Version of the process for which you want to run a test                                          |
| `tests`          | [Test array](/cli/1.1.0/json-test-file.md#test) | <p>List of tests to be run</p><p></p><p>You can define one or several tests in this array.</p>   |
| `deleteRequest`  | Boolean                                         | Indicates whether you want to delete requests that will be launched once the tests have been run |

### Example

```json
{
    "processName": "TEST_PROCESS",
    "processVersion": 1,
    "tests": [...],
    "deleteRequest": false
}
```

## Test

### Parameters

| Parameter           | Type                                                                  | Description                                                                                                                                        |
| ------------------- | --------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `describe`          | String                                                                | Description of the test                                                                                                                            |
| `requestParameters` | [Parameter array](/cli/1.1.0/json-test-file.md#parameter)             | <p>List of parameters that will be transmitted upon launching the request</p><p></p><p>You can define one or several parameters in this array.</p> |
| `actions`           | [Action array](/cli/1.1.0/json-test-file.md#action)                   | <p>List of actions that will be covered by the test</p><p></p><p>You can define one or several actions in this array.</p>                          |
| `assertions`        | [Request assertions](/cli/1.1.0/json-test-file.md#request-assertions) | Checks to be performed on the request created during the test                                                                                      |

### Example

```json
"tests": [
    {
        "describe": "First test",
        "requestParameters": [...],
        "actions": [...],
        "assertions": {...}
    },
    {
        "describe": "First test",
        "requestParameters": [...],
        "actions": [...],
        "assertions": {...}
    }
]
            
```

## Action

{% hint style="info" %}
Test actions will be run in the order that you define.
{% endhint %}

### Parameters

| Parameter        | Type                                                                | Description                                                                                                                                                           |
| ---------------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name`           | String                                                              | Action ID                                                                                                                                                             |
| `operation`      | Enum                                                                | <p>Type of action that will be executed</p><p></p><p>Possible values: <code>COMPLETE</code>, <code>CHECK</code>, <code>SUBPROCESS</code> , or<code>CANCEL</code>.</p> |
| `timeout`        | Int                                                                 | Maximum time for execution of the action                                                                                                                              |
| `parameters`     | [Parameter array](/cli/1.1.0/json-test-file.md#parameter)           | <p>List of parameters that will be transmitted upon launching the request</p><p></p><p>You can define one or several parameters in this array.</p>                    |
| `subRequestFile` | String                                                              | Path to the sub request's JSON test file                                                                                                                              |
| `subRequest`     | [Sub request](/cli/1.1.0/json-test-file.md#sub-request)             | Elements of the sub request                                                                                                                                           |
| `assertions`     | [Action assertions](/cli/1.1.0/json-test-file.md#action-assertions) | Checks to perform on the action                                                                                                                                       |
| `exception`      | [Action exception](/cli/1.1.0/json-test-file.md#action-exception)   | Throw an exception when performing an action                                                                                                                          |

### Example

```json
"actions": [
    {
        "name": "INITIATES",
        "operation": "COMPLETE",
        "parameters": [...],
        "assertions": {...}
    },
    {
        "name": "COPY_DATA",
        "operation": "CHECK",
        "timeout": 10,
        "assertions": {...}
    },
    {
        "name": "SUBTEST_PROCESS",
        "operation": "SUBPROCESS",
        "subRequestFile": "./Resource/Process/Test/subprocessjson.json",
        "assertions": {...}
    }
]
```

{% hint style="info" %}
The content of the sub request file includes only the actions that will be performed.

An example of this content is provided in the [Usage example](/cli/1.1.0/json-test-file.md#usage-example) section.
{% endhint %}

## Sub request

### Parameters

| Parameter    | Type                                                                  | Description                                                                                                               |
| ------------ | --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| `actions`    | [Action](/cli/1.1.0/json-test-file.md#action)                         | <p>List of actions that will be covered by the test</p><p></p><p>You can define one or several actions in this array.</p> |
| `assertions` | [Request assertions](/cli/1.1.0/json-test-file.md#request-assertions) | Checks to be performed on the sub-request created during the test                                                         |

### Example

```json
"subRequest": {
    "actions": [...]
},
"assertions": {...}
```

## Parameter

### Parameters

| Parameter       | Type                                                  | Description                 |
| --------------- | ----------------------------------------------------- | --------------------------- |
| `name`          | String                                                | Name of the data            |
| `numericValue`  | Float                                                 | Numeric value of the data   |
| `textValue`     | String                                                | Text value of the data      |
| `dateTimeValue` | String                                                | Date/time value of the data |
| `fileValue`     | [File value](/cli/1.1.0/json-test-file.md#file-value) | File type value of the data |

### Examples

#### 📌 Example of Test request parameters

```json
"requestParameters": [
    {
        "name": "IN_TEXT",
        "textValue": "Text"
    },
    {
        "name": "IN_NUMERIC",
        "numericValue": 11.1
    },
    {
        "name": "IN_DATETIME",
        "dateTimeValue": "1977-04-22T06:00:00Z"
    },
    {
        "name": "IN_FILE",
        "fileValue": {...}
    }
]
```

#### 📌 Example of Test action parameters

```json
"parameters": [
    {
        "name": "IN_TEXT",
        "textValue": "Text"
    },
    {
        "name": "IN_NUMERIC",
        "numericValue": 11.1
    },
    {
        "name": "IN_DATETIME",
        "dateTimeValue": "1977-04-22T06:00:00Z"
    },
    {
        "name": "IN_FILE",
        "fileValue": {...}
    }
]
```

## Action assertions

### Parameters

| Parameter   | Type                                      | Description                                                                                                                                                                                                             |
| ----------- | ----------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `status`    | Enum                                      | <p>Expected completion status of the action to be performed</p><p></p><p>Possible values: <code>OPEN</code> or <code>CLOSED</code></p>                                                                                  |
| `substatus` | Enum                                      | <p>Expected sub status completion of the action that will be performed</p><p></p><p>Possible values: <code>COMPLETED</code>, <code>ABORTED</code>, <code>RUNNING</code>, or <code>NOT\_RUNNING\_NOT\_STARTED</code></p> |
| `data`      | [Data](/cli/1.1.0/json-test-file.md#data) | List of data to check for the tested action                                                                                                                                                                             |

{% hint style="info" %}
The `assertions` node checks whether the data returned by the action is exactly the same as that specified in its parameters. If they don't match, the test will be evaluated as having failed.
{% endhint %}

### Example

```json
"assertions": {
    "status": "CLOSED",
    "subStatus": "COMPLETED",
    "data": [...]
}
```

## Request assertions

### Parameters

| Parameter              | Type                                      | Description                                                                                                                                                                                                          |
| ---------------------- | ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `completedActionCount` | Int                                       | Expected number of completed actions                                                                                                                                                                                 |
| `status`               | Enum                                      | <p>Expected completion status of the request created during the test</p><p></p><p>Possible types: <code>OPEN</code> or <code>CLOSED</code></p>                                                                       |
| `substatus`            | Enum                                      | <p>Expected completion status of the request created during the test</p><p></p><p>Possible types: <code>COMPLETED</code>, <code>ABORTED</code>, <code>RUNNING</code>, or <code>NOT\_RUNNING\_NOT\_STARTED</code></p> |
| `data`                 | [Data](/cli/1.1.0/json-test-file.md#data) | List of data to check for the request created during the test                                                                                                                                                        |

{% hint style="info" %}
The `assertions` node checks whether the data returned by the request created during the test is exactly the same as that specified in its parameters. If they don't match, the test will be evaluated as having failed.
{% endhint %}

### Example

```json
"assertions": {
    "completedActionCount": 3,
    "requestStatus": "CLOSED",
    "requestSubStatus": "ABORTED",
    "requestData": [...]
}
```

## Data

### Parameters

| Parameter       | Type   | Description                 |
| --------------- | ------ | --------------------------- |
| `name`          | String | Name of the data            |
| `numericValue`  | Float  | Numeric value of the data   |
| `textValue`     | Chaîne | Text value of the data      |
| `dateTimeValue` | Chaîne | Date/time value of the data |

### Example

```json
"requestData": [
    {
        "name": "REQUEST_SUBJECT",
        "textValue": "OK"
    },
    {
        "name": "COPYDATA_VALUE",
        "textValue": "OK"
    }
]
```

## File value

### Parameters

| Parameter     | Type   | Description                           |
| ------------- | ------ | ------------------------------------- |
| `name`        | String | File name, including its extension    |
| `description` | String | Description of the file               |
| `content`     | String | Content of the file encoded in base64 |
| `contentType` | String | File content type                     |
| `size`        | Int    | File size in MB                       |

### Example

```json
"fileValue": {
    "content": "R3JhcGhRTCBGaWxl",
    "contentType": "plain/text",
    "description": "desc",
    "name": "test.txt",
    "size": 12
}
```

## Action exception

### Parameters

| Parameter | Type   | Description                                                                                              |
| --------- | ------ | -------------------------------------------------------------------------------------------------------- |
| `type`    | Enum   | <p>Type of exception to send</p><p></p><p>Possible values: <code>ERROR</code> or <code>CANCEL</code></p> |
| `message` | String | Error message to send to the action                                                                      |
| `source`  | String | Source of the exception to send to the action                                                            |

### Example

```json
"exception": {
    "type": "ERROR",
    "message": "Message",
    "source": "Source"
}
```

## **Usage example**

The `process test` command is based on a `json` file. This definition document allows you to define the flows that will be executed for your tests and the expected results. It consists of 10 different aspects.

Here's the workflow that we'll use for the explanations:

![](/files/-McBmb8INAO7-Cz_2Ndp)

### Test file

This is the content of the parent process test file:

```json
{
    "processName": "TEST_PROCESS",
    "processVersion": 1,
    "tests": [
        {
            "describe": "First test",
            "requestParameters": [],
            "actions": [
                {
                    "name": "INITIATES",
                    "operation": "COMPLETE",
                    "parameters": [
                        {
                            "name": "REQUEST_SUBJECT",
                            "textValue": "OK"
                        }
                    ],
                    "assertions": {
                        "status": "CLOSED",
                        "subStatus": "COMPLETED"
                    }
                },
                {
                    "name": "COPY_DATA",
                    "operation": "CHECK",
                    "timeout": 10,
                    "assertions": {
                        "status": "CLOSED",
                        "subStatus": "COMPLETED",
                        "data": [
                            {
                                "name": "COPYDATA_VALUE",
                                "textValue": "OK"
                            }
                        ]
                    }
                },
                {
                    "name": "SUBTEST_PROCESS",
                    "operation": "SUBPROCESS",
                    "subRequestFile": "./Resource/Process/Test/subprocessjson.json",
                    "assertions": {
                        "status": "CLOSED",
                        "subStatus": "COMPLETED"
                    }
                }
            ],
            "assertions": {
                "completedActionCount": 3,
                "requestStatus": "CLOSED",
                "requestSubStatus": "COMPLETED",
                "requestData": [
                    {
                        "name": "REQUEST_SUBJECT",
                        "textValue": "OK"
                    },
                    {
                        "name": "COPYDATA_VALUE",
                        "textValue": "OK"
                    }
                ]
            }
        },
        {
            "describe": "Second test",
            "requestParameters": [],
            "actions": [
                {
                    "name": "INITIATES",
                    "operation": "COMPLETE",
                    "parameters": [
                        {
                            "name": "REQUEST_SUBJECT",
                            "textValue": "OK"
                        }
                    ]
                },
                {
                    "name": "COPY_DATA",
                    "operation": "CHECK",
                    "timeout": 10,
                    "assertions": {
                        "status": "CLOSED",
                        "subStatus": "COMPLETED",
                        "data": [
                            {
                                "name": "COPYDATA_VALUE",
                                "textValue": "OK"
                            }
                        ]
                    }
                },
                {
                    "name": "SUBTEST_PROCESS",
                    "operation": "SUBPROCESS",
                    "subRequest": {
                        "actions": [
                            {
                                "name": "INITIATES",
                                "operation": "COMPLETE",
                                "parameters": [
                                    {
                                        "name": "REQUEST_SUBJECT",
                                        "textValue": "OK"
                                    }
                                ]
                            },
                            {
                                "name": "VALIDATES",
                                "operation": "COMPLETE",
                                "parameters": [
                                    {
                                        "name": "APPROVAL_DECISION",
                                        "textValue": "MORE_INFO"
                                    }
                                ]
                            },
                            {
                                "name": "UPDATES",
                                "operation": "COMPLETE",
                                "timeout": 5,
                                "parameters": [
                                    {
                                        "name": "REQUEST_SUBJECT",
                                        "textValue": "OK"
                                    }
                                ]
                            },
                            {
                                "name": "VALIDATES",
                                "operation": "COMPLETE",
                                "parameters": [
                                    {
                                        "name": "APPROVAL_DECISION",
                                        "textValue": "YES"
                                    }
                                ]
                            }
                        ]
                    },
                    "assertions": {
                        "status": "CLOSED",
                        "subStatus": "COMPLETED"
                    }
                }
            ],
            "assertions": {
                "completedActionCount": 3,
                "requestStatus": "CLOSED",
                "requestSubStatus": "COMPLETED",
                "requestData": [
                    {
                        "name": "REQUEST_SUBJECT",
                        "textValue": "OK"
                    },
                    {
                        "name": "COPYDATA_VALUE",
                        "textValue": "OK"
                    }
                ]
            }
        },
        {
            "describe": "Third test",
            "requestParameters": [],
            "actions": [
                {
                    "name": "INITIATES",
                    "operation": "COMPLETE",
                    "parameters": [
                        {
                            "name": "REQUEST_SUBJECT",
                            "textValue": "OK"
                        }
                    ]
                },
                {
                    "name": "COPY_DATA",
                    "operation": "CHECK",
                    "timeout": 10,
                    "assertions": {
                        "status": "CLOSED",
                        "subStatus": "COMPLETED",
                        "data": [
                            {
                                "name": "COPYDATA_VALUE",
                                "textValue": "OK"
                            }
                        ]
                    }
                },
                {
                    "name": "SUBTEST_PROCESS",
                    "operation": "SUBPROCESS",
                    "subRequest": {
                        "actions": [
                            {
                                "name": "INITIATES",
                                "operation": "COMPLETE",
                                "parameters": [
                                    {
                                        "name": "REQUEST_SUBJECT",
                                        "textValue": "OK"
                                    }
                                ]
                            },
                            {
                                "name": "VALIDATES",
                                "operation": "CANCEL",
                                "exception": {
                                    "type": "ERROR",
                                    "message": "Message",
                                    "source": "Source"
                                },
                                "assertions": {
                                    "status": "CLOSED",
                                    "subStatus": "ABORTED"
                                }
                            }
                        ]
                    },
                    "assertions": {
                        "status": "CLOSED",
                        "subStatus": "ABORTED"
                    }
                }
            ],
            "assertions": {
                "completedActionCount": 3,
                "requestStatus": "CLOSED",
                "requestSubStatus": "ABORTED",
                "requestData": [
                    {
                        "name": "REQUEST_SUBJECT",
                        "textValue": "OK"
                    },
                    {
                        "name": "COPYDATA_VALUE",
                        "textValue": "OK"
                    }
                ]
            }
        },
        {
            "describe": "Fourth test",
            "requestParameters": [],
            "actions": [
                {
                    "name": "INITIATES",
                    "operation": "COMPLETE",
                    "parameters": [
                        {
                            "name": "REQUEST_SUBJECT",
                            "textValue": "OK"
                        }
                    ]
                },
                {
                    "name": "COPY_DATA",
                    "operation": "CHECK",
                    "timeout": 10,
                    "assertions": {
                        "status": "CLOSED",
                        "subStatus": "COMPLETED",
                        "data": [
                            {
                                "name": "COPYDATA_VALUE",
                                "textValue": "OK"
                            }
                        ]
                    }
                },
                {
                    "name": "SUBTEST_PROCESS",
                    "operation": "SUBPROCESS",
                    "subRequest": {
                        "actions": [
                            {
                                "name": "INITIATES",
                                "operation": "COMPLETE",
                                "parameters": [
                                    {
                                        "name": "REQUEST_SUBJECT",
                                        "textValue": "OK"
                                    }
                                ]
                            },
                            {
                                "name": "VALIDATES",
                                "operation": "CANCEL",
                                "assertions": {
                                    "status": "CLOSED",
                                    "subStatus": "ABORTED"
                                }
                            }
                        ]
                    },
                    "assertions": {
                        "status": "CLOSED",
                        "subStatus": "ABORTED"
                    }
                }
            ],
            "assertions": {
                "completedActionCount": 3,
                "requestStatus": "CLOSED",
                "requestSubStatus": "ABORTED",
                "requestData": [
                    {
                        "name": "REQUEST_SUBJECT",
                        "textValue": "OK"
                    },
                    {
                        "name": "COPYDATA_VALUE",
                        "textValue": "OK"
                    }
                ]
            }
        }
    ],
    "deleteRequest": false
}
```

### subRequestFile

This is the content of the `subprocessjson.json` test file, used in the first test for the `SUBTEST_PROCESS` action:

```json
{
    "actions": [
        {
            "name": "INITIATES",
            "operation": "COMPLETE",
            "parameters": [
                {
                    "name": "REQUEST_SUBJECT",
                    "textValue": "OK"
                }
            ]
        },
        {
            "name": "VALIDATES",
            "operation": "COMPLETE",
            "parameters": [
                {
                    "name": "APPROVAL_DECISION",
                    "textValue": "YES"
                }
            ]
        }
    ]
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.workflowgen.com/cli/1.1.0/json-test-file.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
