# Tests

Write test cases with acceptance criteria and let a review model check every change of the agent

> Full REST + WebSocket API reference: https://api.happ.tools/reference

**Tests** catch a bad answer before a customer sees it. You describe a conversation and what the agent must (and must not) do; Happ plays it in a hidden playground chat — same prompt, model, tools and knowledge base as live chats — and a **review model** judges the dialogue: **Passed** or **Failed**, a score from 0 to 1 and a verdict.

Open it from the agent sidebar: **Monitor** > **Test**. Tests run as text chats; to check the voice, use **Test with a call** in the top bar.

<TestsPageDemo />

## Add a test case [#add-a-test-case]

**Add case** opens the editor:

| Field                             | What it does                                                                                                                                       |
| --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| Name                              | Up to 300 characters, e.g. "Finds a product in the catalogue"                                                                                      |
| Mode                              | **AI client** — a model plays the customer from your scenario (up to 12 turns). **Script** — up to 10 client messages sent word for word, in order |
| Client scenario / Client messages | Who the customer is, what they want, the data they give — or the exact messages                                                                    |
| Acceptance criteria               | What the agent must do and must not, e.g. "Calls search\_in\_vector() before quoting a price"                                                      |
| Dynamic variables                 | Values for `{{placeholders}}` in the prompt during this test — as on a real call                                                                   |
| Tool mocks                        | Fake responses for tools (see below)                                                                                                               |
| Spend limits                      | **Max messages in dialog** (2–200) and &#x2A;*Max cost, $**. Exceeding a limit stops the case with an error                                        |

New cases are saved **switched off**: turn on **Run with all** in the table to include them in **Run all**.

**Suggest (AI)** drafts cases for you: the model reads the agent's prompt, tools and knowledge base. Add an optional focus ("refunds, rude clients"), pick how many (1–10), keep the ones worth keeping.

## Mock the tools [#mock-the-tools]

**Tool calls in tests are real unless mocked** — a test can create a real order in your CRM. Mock anything that changes data:

* **Mock all tools** — every tool call in every test of this agent gets a mock response.
* **This test / All tests** — mock one tool for one case or for the whole agent. Rules are checked top to bottom, the first match wins; a rule can match on a call argument (`parameter = value`) and can return an error.

## Run [#run]

* **Run all** runs every switched-on case; ▶ on a row runs one case, even a switched-off one.
* **Run on** picks the main version or a [draft](/docs/agents/versions) — test an experiment before it goes live.
* **Review model** — the judge's model. Default is the agent's; a different, stronger one is a better judge.

Before every run Happ shows an estimate: cases, models, tokens and **estimated cost**. Cases run three at a time.

## Read the results [#read-the-results]

**Runs** lists every run with its status (**Queued**, **Running**, **Completed**, **Failed**), passed / total, tokens, cost and duration. Open a run to see:

* **regressed** and **fixed** cases compared with the previous run;
* each case: score, the judge's **verdict**, the full **dialogue** with every tool call and its input and output;
* **Suggest a fix** — a minimal edit to the prompt that would make the case pass. It's a suggestion: apply it yourself, then run the case again.

A case gets **Error** instead of **Failed** when it couldn't finish: a limit was hit, a tool broke, or the judge answered nonsense.

**API:** [api.happ.tools/reference](https://api.happ.tools/reference)

## Next [#next]

* [Versions and drafts](/docs/agents/versions) — test an experiment in a draft
* [Auditor](/docs/agents/auditor) — check answers live, not only in tests
* [Tools](/docs/agents/tools) — what the agent can call
