> For the complete documentation index, see [llms.txt](https://docs.crobox.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.crobox.com/how-to-guides/sagent/qa/test-cases.md).

# Test Cases

Create prompts and assertions for regression testing.

**Test Cases** define the prompts and expected behavior used to check Sagent. They turn important customer journeys and safety requirements into repeatable release checks.

Use test cases to protect behavior that matters to your business. Update them when you intentionally change Sagent’s configuration or capabilities.

Use **Test Cases** to create and maintain the prompts and assertions used in regression testing.

{% stepper %}
{% step %}

#### Create a test case

Open **QA → Test Cases**. Click **New test case**.
{% endstep %}

{% step %}

#### Name the test

Enter a clear name that describes the scenario being tested.
{% endstep %}

{% step %}

#### Add the prompt

Enter the shopper or adversarial prompt Sagent should answer.
{% endstep %}

{% step %}

#### Add assertions

Click **Add assertion**. Select an assertion type, then add a value when that type requires one.

Add more assertions when the response must meet several conditions. Click **Save** when finished.
{% endstep %}
{% endstepper %}

### Choose an assertion type

Use assertions to define how QA grades Sagent's response.

#### LLM-graded assertions

* **LLM Rubric** — grades the response against a custom rubric. Describe expected behaviour in plain English.
* **Factuality** — compares the response with an expected fact. It checks whether the response agrees, contradicts, or is unrelated.
* **Closed QA** — checks whether the response correctly answers a closed question using the reference answer.
* **Answer Relevance** — scores how relevant the response is to the original prompt. No value is required.

#### String matching

String matching is fast and has no LLM cost.

* **Not Contains** — checks that the response does not contain an exact, case-sensitive string.
* **Not Contains (case-insensitive)** — checks that the response does not contain a string, regardless of case.
* **Contains** — checks that the response contains an exact, case-sensitive string.
* **Contains (case-insensitive)** — checks that the response contains a string, regardless of case.

#### Pattern matching

Pattern matching is fast and has no LLM cost.

* **Not Regex** — checks that the response does not match a regular expression. Use it to block patterns such as prices or URLs.
* **Regex** — checks that the response matches a regular expression pattern.

#### Tool usage

Tool-usage assertions are fast and have no LLM cost.

* **Used Question Tool** — passes when Sagent asks a clarifying question through the question tool. No value is required.
* **Used Product Search Tool** — passes when Sagent returns product results through the product-search tool. No value is required.

#### Safety

* **Is Refusal** — detects whether a response is a refusal. It supports English only and has no LLM cost. Use an **LLM Rubric** alongside it for multilingual testing.
* **Moderation** — uses the OpenAI Moderation API to check for harmful, violent, or explicit content. No value is required.

### Frequently asked questions

<details>

<summary>Can a test case have more than one assertion?</summary>

Yes. Add an assertion for every condition the response must meet.

</details>

<details>

<summary>When should I use an LLM Rubric?</summary>

Use an LLM Rubric when expected behaviour needs plain-language criteria. Use a more specific assertion when you need to check a fact, fixed answer, or exact string.

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.crobox.com/how-to-guides/sagent/qa/test-cases.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
