> For the complete documentation index, see [llms.txt](https://docs.coherent.global/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coherent.global/navigation/testing-center/testbeds.md).

# Testbeds

In the **Testing Center**, a Spark service can be applied against a dataset to determine the calculated outputs for many records at a time. The main use cases for this feature are for regression testing, model simulation, and portfolio projection use cases.

After choosing a specific service from the [Folder overview](/navigation/folder-overview.md), select the ![Testing Center](https://2714190325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fc7fek1ZgAUH5MA3m5pH8%2Fuploads%2FPiT25E5YNa2osaI9hU0N%2Fimage.png?alt=media\&token=863925f0-45c2-47c9-af26-589e5e656b44) icon from the service sidebar. The first screen in **Testing Center** is the testbeds screen.

## Testing Center terminology

* A test case is a single test case record. A test case can be composed of multiple single value and table inputs.
* A testbed contains multiple test cases.
* After a testbed is run against a Spark service, the output is a testbed result. It should contain the same number of records as the testbed.

## Add new testbed

### Import your own testbed

1. If a service does not have any testbeds, you will be asked to create one. If the service has testbeds already, you can add another testbed by selecting **New testbed**.
2. Select **Add test cases**.
3. You can upload either an Excel file or `CSV` file.
   * Excel file:
     1. **Need the template file to add your test cases?** Select **Download it here**. The template is based on the inputs from the latest service version.
     2. Open the downloaded Excel file. The file includes a table with the input names as headings.
     3. Follow the instructions in the file to add test cases.
   * `CSV` file:
     1. The CSV file must contain headers in the first row. These should correspond to the names of inputs in the Spark service.
     2. Add the corresponding test data under the headers.
     3. You can add a column for **Description** which is read by Spark to describe each test case.
   * [API Call History](/navigation/api-call-history.md#download-api-calls) **Excel** file can also be imported directly as a testbed.
4. Select **Browse** or drag the workbook into the upload area. Spark supports `.xlsx`, `.xlsm`, and `.csv` files.
5. Enter a **Testbed name**. By default, this is read from either inside the workbook or based on the filename.
6. Optionally, enter a **Testbed description**.
7. Select **Upload**.
8. The new testbed will be listed in the table.

#### Handle null values

To set an input as `null`:

* For Excel testbed uploads, an empty cell will be considered as `null`.
* For CSV testbed uploads, an entry that is `null` will be considered as `null`.

Similar to the [Execute API](/spark-apis/execute-api.md), the treatment of `null` is different for single value and table inputs.

* For single value inputs, a `null`, is equivalent to clearing the cell in Excel and numerically equal to `0`.
* If a table is set to a singular `null`, then the default value will be used for that input.

### Randomized test case generation

Generate test cases randomly based on your input parameters. This is good for broad testing coverage.

1. If a service does not have any testbeds, you will be asked to create one. If the service has testbeds already, you can add another testbed by selecting **New testbed**.
2. Select **Randomized test case generation**.
3. Enter a **Testbed name**.
4. Select a **Service version**. By default, the latest service version is selected. The inputs generated will be based on the selected service version.
5. If your service has [Sub functions with subservices](/build-spark-services/additional-mappings/sub-functions-with-subservices.md), you can select which subservices to include.
6. Optionally, enter a **Testbed description**.
7. Select **Next**.
8. Enter the **Number of test cases**. The default number is `100`.
9. For each input, Spark automatically identifies the range of values based on the Data Validation defined in Excel.
   * For categorical inputs where the input range is finite, a subset of the field values can be included in the test case generation.
   * For numerical inputs, there are options to define the minimum, maximum, and step size.
   * Fields that have dynamic validation that depends on other fields can be automatically updated with the correct dependencies.
   * If an `Xinput` is larger than `1 row x 1 column`, then the default values will be used for every test case.
10. Select **Generate test cases**.
    1. You can monitor the progress in the modal.
    2. Alternatively, you can **Minimize** the modal and monitor progress in **Background activity**. Once it is completed, select the **Generate testbed** activity.
11. When the process is complete, a modal will appear to show a summary of the resulting testbed.
12. If you want to run this testbed, select **Run**. Follow the instructions in [#run-testbed](#run-testbed "mention").

### Systematic test case generation

Generate test cases systematically to cover all scenarios based on your input parameters. This is good for broad testing coverage to try to ensure coverage across permutations and input levels.

1. If a service does not have any testbeds, you will be asked to create one. If the service has testbeds already, you can add another testbed by selecting **New testbed**.

2. Select **Systematic test case generation**.

3. Enter a **Testbed name**.

4. Select a **Service version**. By default, the latest service version is selected. The inputs generated will be based on the selected service version.

5. Optionally, enter a **Testbed description**.

6. Select the method in which the permutations are generated:

   | Method                                                                                                                                                       | Permutations                                                                                    | Example                                                                                                                                                                                                                                |
   | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
   | **All Permutations**: Spark will generate every possible combination across the single value inputs.                                                         | Maximum number such that every combination is tested.                                           | <p>If <code>A ∈ {1,2,3}</code>  and  <code>B ∈ {6,7}</code>.<br>The <code>6</code>  combinations generated are <code>1,6</code>, <code>1,7</code>, <code>2,6</code>, <code>2,7</code>, <code>3,6</code>, <code>3,7</code>. </p>        |
   | **Single Change Permutations**: With the default values as the base test case, for each single value input level, Spark will create an additional test case. | <p>Minimum number necessary such that each single value input level is tested once.<br><br></p> | <p>If <code>A ∈ {1,2,3}</code>  and  <code>B ∈ {6,7}</code> and the default values are <code>1,6</code>.<br>the <code>4</code> combinations generated are <code>1,6</code>, <code>2,6</code>, <code>3,6</code>, <code>1,7</code>. </p> |

7. For each of the inputs, you can adjust the number of variations. Select the input name to open the **Edit** pane. The variations can be modified by changing the **Generation type** and parameter&#x73;**.**

8. | Generation type                                                                                                     | Details                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
   | ------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
   | **List**: Generate test cases for all the listed options.                                                           | <ul><li>If there is a <strong>List</strong> type data validation for this input in Excel, those values will be shown as the starting list. Otherwise, the default value will be the only initial item in the list.</li><li>Remove variations by selecting the <code>x</code> button.</li><li>To add new variations, click into the input box and begin typing. Hit <strong>Enter</strong> to create an option.</li><li>The number of variations is the same as the number of options.</li></ul>                                                                                                                                                                                                                                                                                                                                                                        |
   | **Random list**: Systematically generate test cases from a randomly selected number of items in the listed options. | <ul><li>If there is a <strong>List</strong> type data validation for this input in Excel, those values will be shown as the starting list. Otherwise, the default value will be the only initial item in the list.</li><li><p>The test cases will systematically step through a randomly predetermined list of the items until the desired number of variations has been reached.</p><ul><li>If there are more options than the desired number of variations, not every item will be used.</li><li>If there are fewer options than the desired number of variations, some items will be repeated</li></ul></li><li>To remove a variation, click the <code>x</code> button.</li><li>To add new variations, click into the input box and begin typing. Hit <strong>Enter</strong> to create a variation.</li><li>You can also select the number of variations.</li></ul> |
   | <p><strong>Number range</strong>: Generate test cases to cover all the defined steps within a range.<br></p>        | <ul><li>The <strong>Number range</strong> input type works similarly to "for loops" in many programming languages. Conceptually, think of skip counting: start at the value for <code>min</code> and skip count by the <code>step size</code> until arriving at the <code>max</code> (or the next number will be greater than the <code>max</code>).</li><li><p>Example: <code>min: 0</code>, <code>max: 20</code>, <code>step size: 5</code>.</p><ul><li>The sequence would be <code>0, 5, 10, 15, 20</code>, producing <code>5</code> variations.</li><li>If the <code>max</code> was <code>23</code>, the sequence would still stop at <code>20</code> because the next number <code>25</code> exceeds the <code>max</code>.</li></ul></li></ul>                                                                                                                    |
   | **Random number range**: Generate test cases selected randomly from all the defined steps within a range.           | <ul><li>This functions the same as Number range but instead selects the desired number of items from the total number range list and iterates through it to create its variations.</li><li>Similar to <strong>Random list</strong>, the test cases will systematically step through the same list of randomly selected items until the desired number of variations has been reached. If there are more options than the desired number of variations, not every item will be used. If there are fewer options than the desired number of variations, some items will be repeated.</li></ul>                                                                                                                                                                                                                                                                           |
   | **Static table**: For multi-cell range inputs.                                                                      | <ul><li>For multi-cell range inputs, the only input type available is <strong>Table</strong>. This works similarly to the <strong>List</strong> input type for single-cell inputs, except that the value is the JSON-formatted string representing the table.</li><li>This table will be repeated for every record.</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
   * Data validation in the Excel file is used to populate the initial set of variations for **List** and **Range** generation types.
   * Fields that have dynamic validation that are dependent on other fields can be automatically generated with the correct dependencies but the variations can only be randomly selected.

9. The total number of estimated test cases generated is indicated at the bottom. If the test cases are excessive, the testbed may be truncated.

10. Select **Generate test cases**.
    1. You can monitor the progress on the screen.
    2. Alternatively, you can **Minimize** the screen and monitor progress in **Background activity**. Once it is completed select the **Generate testbed** activity.

11. The new testbed will be listed in the table.

## Change how testbeds are displayed

* **Search**: Enter a search term and the list will update.
* **Favorite** **testbeds**: Favorite testbeds are displayed first.
* **Sort**: Change the sort order by selecting the **List view** headers.
* **List view** / **Card view**: The default **Card view** shows services and documents as tiles. **List view** is more compact and displays one item per line.

## Testbed actions

Additional actions can be performed on a testbed from the ellipsis menu.

### View testbed details

Select a testbed name to go to [Testbed details](/navigation/testing-center/testbed-details.md).

### Run testbed

Select ▶️ **Run** to run a testbed.

1. Select the **Service version** that you want to run the testbed against.
2. **Select service type**: Stay with the default selection of **Neuron**.
3. **Select execution mode**: **Legacy** execution is the current method of running tests. **Batch** execution mode is experimental - it should require less configuration for batch size and should process in a shorter period of time.
4. Enter a **Testbed result name**.
5. Optionally, enter a **Testbed result description**.
6. If your service has [Sub functions with subservices](/build-spark-services/additional-mappings/sub-functions-with-subservices.md), you can select which subservices to include.
7. Select **Run**.
   1. You can monitor the progress in the modal.
   2. Alternatively, you can **Close** the modal and monitor progress in **Background activity**. Once it is completed select the **Run testbed** activity.
8. The **Run testbed** modal should indicate **This testbed was successfully run.** with some statistics about the testbed result.
9. To download the result immediately, select **Download result**. Follow the instructions in [Testbed details](/navigation/testing-center/testbed-details.md#download-testbed-result).

{% hint style="warning" %}
If you encounter an error relating to timeout and batch size, we suggest the following actions:

* Edit the [Service Documentation](/navigation/service-documentation.md#version-details) **Batch Size Override** to a lower number. This reduces the number of test cases that are submitted at a time which reduces the likelihood of a timeout as fewer records will be processed together. The default batch size value is `100`.
* If you frequently encounter this across many Spark services, the batch size value can be adjusted for new services. This can be done by contacting [Support](/support/faq.md).
  {% endhint %}

### Favorite testbed, Unfavorite testbed

Favorite testbeds can be filtered on the home screen using the toggle.

### Download testbed

| Format                                  | Description                                                                                                                                |
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| **Download as CSV**                     | Return the testbed in a `ZIP` file containing `CSV` files. Files are chunked at `25 MB`.                                                   |
| **Download as Excel**                   | Return the testbed in a single Excel file.                                                                                                 |
| **Download as Excel (expanded tables)** | **Excel** plus **expanded tables** will write table inputs to separate worksheets making it easy to review test cases that include tables. |

1. The download task initiates and can be monitored in **Background activity**.
2. Once the download is ready, it will automatically start to download.
3. If you missed the download, the download can be initiated again in **Background activity**.

### Delete testbed

Before a testbed is deleted, Spark will request confirmation for the delete action. After confirmation, everything related to the testbed will be deleted. There is no process to recover deleted testbeds.
