> ## Documentation Index
> Fetch the complete documentation index at: https://docs.phonely.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Unit Testing

> Run repeatable AI-generated conversations and evaluate how your agent responds.

Unit Testing runs AI-generated conversations against your agent before you rely on a change in live calls. Use it to exercise a defined scenario repeatedly, check expected behavior, and compare results across runs.

Unit tests complement—not replace—[Web Chat, Web Call, and phone testing](/flow-editor/test-and-publish). They are most useful for repeatable scenarios and regression checks.

## Create a test case

Open **Testing > Unit Testing**, select **Test Cases**, then add a test case.

| Setting       | What it controls                                                 |
| ------------- | ---------------------------------------------------------------- |
| Case Name     | Identifies the scenario in the test list and results             |
| Description   | Describes the caller, situation, and behavior to exercise        |
| Test Instance | How many conversations to run for the scenario                   |
| Variance      | How much the generated conversations may differ from one another |

Write the description as a concrete caller scenario. Include the caller's goal and any important constraints, but do not prescribe the agent's response—the agent should follow its own configuration.

<Note>
  Each test run can incur usage charges. The current limits and price are shown in the test form before you run it.
</Note>

## Choose data sources and evaluators

Use **Data Sources** to define the conversations or criteria associated with a test case:

* **Call Recordings** are recordings you upload for testing.
* **Phonely's Calls** are calls already handled by the agent.
* **AI Evaluator** defines an AI-generated caller and the criteria used to judge the interaction.

Select only sources that represent the behavior you want the test case to cover. Keep evaluators focused on one scenario so a failed result is easier to understand.

## Run tests

Run an individual test case from its card, or select **Run All Tests** to run every configured case for the agent. Phonely moves the new run to **Test Results** while it is processed.

Changing the agent does not retroactively change an earlier result. Run the relevant cases again after modifying prompts, flows, knowledge, voice behavior, or other settings that affect the scenario.

## Review results

Open **Test Results** and select a run to review its overall result and individual test instances. The result identifies the test case snapshot, AI evaluator, and status for each generated conversation.

Review failed and inconsistent instances individually. A useful follow-up is to compare their conversation paths and determine whether the issue comes from the scenario, the evaluator, or the agent configuration.

<AccordionGroup>
  <Accordion title="A test does not exercise the expected behavior">
    Make the test case description more specific, confirm that the selected data sources and evaluator represent the intended scenario, then run it again. Also verify that the agent version you intended to test contains the relevant changes.
  </Accordion>

  <Accordion title="Results vary too much between runs">
    Lower **Variance**, narrow the scenario, and separate unrelated goals into different test cases. Some variation is expected because the conversations are generated by AI.
  </Accordion>

  <Accordion title="A result remains in progress or fails to run">
    Refresh **Test Results** and retry the case. If it fails again, reduce the number of instances and verify that the agent and selected data sources are still available.
  </Accordion>
</AccordionGroup>
