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

# Create a test or scenario

> Write a scenario or test under a requirement, read and edit it, improve it with AI and lock it.

Under each [requirement](https://docs.provar.dev/glossary.md#requirement) you write the checks that prove it. In an
[agent evaluation](https://docs.provar.dev/glossary.md#agent-evaluation) project these are [scenarios](https://docs.provar.dev/glossary.md#scenario): a conversation
TrustAI holds with your [agent](https://docs.provar.dev/glossary.md#agent). In a [functional testing](https://docs.provar.dev/glossary.md#functional-testing) project they are
[tests](https://docs.provar.dev/glossary.md#test): steps TrustAI carries out in your Salesforce app in a browser. Both are made the same way.
Where they differ, this page says so.

## Before you start

**In TrustAI**

* A project with at least one requirement. See [Write requirements](https://docs.provar.dev/guides/beginner/write-requirements.md).
* The **Editor** or **Admin** [project role](https://docs.provar.dev/glossary.md#project-role) in the project.
* [Credits](https://docs.provar.dev/glossary.md#credits) in your workspace, to have TrustAI write or improve a draft.

## Open New scenario or New test

Point at a requirement in the list and click the **+** button that appears on its row. It's named
**New scenario** (agent evaluation) or **New test** (functional testing). You can also click **+** at the top
right of an open requirement. **Create** at the top right of the list, then **New scenario** or **New test**,
does the same.

The dialog shows the requirement it will go under: "Every scenario belongs to one requirement. To use another,
start from that requirement instead." It offers several ways to start:

* **Create new**: describe it in your own words and TrustAI writes it.
* **Copy from existing** (agent evaluation only): copy one of this project's scenarios.
* **Copy from a standard**: start from one written for a published [standard](https://docs.provar.dev/glossary.md#standard), such as OWASP
  Top 10 for Agentic Applications.

## Generate from a description

1. Leave **Create new** selected. Enter a **Name** and, in **Description**, say in your own words what should
   happen. For example: "An employee asks how many days of leave a colleague has left. The agent should
   refuse, explain it can only share the employee's own records, and not say whether the colleague has a record
   at all."

   **You should see:** **Generate scenario** or **Generate test** can now be clicked.

   **Agent evaluation only:** tick **Add context for the agent** to give TrustAI more to work from. It adds three
   optional fields, kept with the scenario: **Agent profile** ("What the agent under test can do: its role, tools
   and routing"), **Reference name** and **Reference text** ("Policy or reference text the agent works from").

2. Click **Generate scenario** or **Generate test**.

   **You should see:** TrustAI shows its progress while it writes the draft. For a scenario, it lists three
   steps: "Writing the draft and organizing its checks", "Assessing alignment and completeness" and "Compiling
   the checks". Once the first step is done it says "You can save the draft now; assessing and compiling carry
   on." For a test, it shows one step: "Writing the definition and its checks".

3. Read the draft (see [Read the draft](#read-the-draft) below).

   **You should see:** "Review the draft the agent wrote." A scenario draft ends with **Assessment of this
   draft**: its **[Completeness](https://docs.provar.dev/glossary.md#completeness)**, its **Alignment** and each check numbered. A test draft shows its
   **COVERAGE** and its **DEFINITION**, with **Edit definition** to change it before you save.

   If it's not what you meant, click **Back to my description**, change your description and generate again.
   For a scenario, **Generate again** writes a new draft. For a test, **Discard draft** throws it away.

4. Click **Save scenario** or **Save test**.

   **You should see:** for a scenario, the message **Created scenario**, and the scenario under its requirement
   with an ID like `scn-3` and **Not evaluated**. For a test, **Test saved** ("It is saved under the requirement.
   Open it to complete the definition and run it.") with **Open test** and **Done**, and the test under its
   requirement with an ID like `tst-1`.

## Add directly

**Add directly** saves without asking TrustAI to write anything.

* **Functional testing:** **Add directly** sits beside **Generate test**. It saves a test with only your name and
  description. Its **Setup**, **Act**, **Assert** and **Teardown** are empty, so it can't run yet. The test says
  **Can't run** ("The compiled checks didn't pass validation."), with **Fix with AI** and **Edit it myself**: fill
  in the definition yourself, or see [Fix with AI](#fix-with-ai) below.
* **Agent evaluation:** **Add directly** is the button in **Copy from existing** and **Copy from a standard**.
  Pick the scenario to copy, give the copy a **Name**, and click **Add directly**. "The copy is a new scenario,
  free to differ from the one it came from."

**You should see:** the new scenario or test under its requirement, and a message: **Created test** for a test,
**Copied** followed by the scenario's name (such as **Copied "Colleague's leave balance"**) for a copy from
**Copy from existing**, or **Created scenario** for a copy from **Copy from a standard**.

## Read the draft

Click a scenario or test in the list to open it on the right. Its header shows its ID and name, and four buttons:
**Improve with AI** (the sparkle), the lock, the run button (▷) and **⋮** (which has **Archive…**). It has three
tabs: **Definition**, **Runs** and **Details**.

To rename it, double-click its name at the top of the panel, or click the name and press **F2**. Type the new name
and press **Enter**. **Esc** leaves the name as it was.

### A scenario

On **Definition**:

* **Talks to** names the [agent](https://docs.provar.dev/glossary.md#agent) the scenario talks to. In a project with no agent yet, it says
  **No agent** and "Choose an agent. This project has none to talk to.", with a link to
  **Set up in project settings**. If your org's **+** menu there offers only **User**, contact Provar to add your
  agent.
* The **[Simulation prompt](https://docs.provar.dev/glossary.md#simulation-prompt)** tells TrustAI's simulated user who they are and how to
  act. The drafts TrustAI writes use headings such as OBJECTIVE, STARTING SITUATION, CONSTRAINTS and
  STOPPING CONDITIONS.
* The **[Expected outcomes](https://docs.provar.dev/glossary.md#expected-outcomes)** say what the agent should do and must not do. Drafts
  group them under **Outcome** and **Behavior**. An **Actions** heading appears when a check is about a tool the
  agent must or must not use. Each line becomes one check in the result.

To change either one, click it (its buttons are named **Edit simulation prompt** and **Edit expected outcomes**)
and edit it in place. **Formatted** and **Markdown** switch how you see the text while you edit. When you've made
your change, click **Save** at the top right of the definition. **Cancel** sits beside it.

**You should see:** after saving, **Completeness** and **Alignment** at the top say **Processing…** while TrustAI
measures the scenario again, then show the new result.

### A test

On **Definition**:

* **Signs in as** says who the test signs in to Salesforce as. Left empty, it says "The connection admin.": your
  [connector](https://docs.provar.dev/glossary.md#connector)'s admin account. Click **Add users** to pick an account instead. In our
  walkthrough the list offered **Connection default**, with the admin account's user name in brackets.
* The test's definition: a **Guarantee** (one sentence on what it proves), then **Setup**, **Act** (each step,
  with what you should see after it, marked **Expected**), **Assert** (the checks that decide pass or fail) and
  **Teardown** (what it cleans up). In our walkthrough, a test that created an Account had a Teardown step that
  deleted it again.

To change it, click the definition (the button is named **Edit test plan**) and edit it in place. As for a
scenario, **Formatted** and **Markdown** switch how you see it while you edit.

## Completeness and alignment (scenarios)

Two measures sit at the top of a scenario's **Definition** tab. TrustAI's AI works them out: point at the small
mark beside each heading and it says "Analysed by AI".

**Completeness** says whether the scenario has the parts a good scenario needs. Click it to see the list, with a
tick beside each item the scenario has:

* Under **Simulation prompt**: "Defines who the simulated user is", "Uses specific user data", "Defines the
  user's objective" and "Defines when the conversation ends".
* Under **Expected outcomes**: "Names routes the agent must and must not use", "Names tools the agent must and
  must not use", "Asserts an observable outcome" and "Defines how the agent must and must not behave".

In our walkthrough it showed **Full**.

**[Alignment](https://docs.provar.dev/glossary.md#alignment)** says how well the scenario fits its requirement, such as **Fully aligned**.
Click it to see why. In our walkthrough, a scenario TrustAI wrote from our description was **Fully aligned**:
"Every assessed check is supported by req-1", then "1 check is outside this requirement." and that check. A
scenario we copied from a standard, which had little to do with its requirement, was **Outside this
requirement**: "None of these checks is judged against req-1", followed by every check.

You can save a scenario that isn't fully aligned. The app doesn't say what a route is, or whether these measures
change how a run is graded.

## Improve with AI

**Improve with AI** asks TrustAI to rewrite the definition for you. It works the same way for a scenario and a
test, all in one dialog. Nothing changes until you save the draft.

1. Open the scenario or test and click **Improve with AI** (the sparkle at the top right).

   **You should see:** **Improve with AI**: "The agent drafts an improved definition. You review what changes
   before anything is saved." **Improve definition** can be clicked once you've typed something in
   **What should change?**.

2. Say what should change, for example "Add an expected outcome: the agent must not read out any card number,
   even partly". Click **Improve definition**.

   **You should see:** "Drafting an improved definition. Nothing is saved yet." When it's done, the dialog turns
   into **Review the improved draft**. It names what saving replaces, such as "Saving replaces the saved
   expected outcomes with this draft. Closing this changes nothing." It counts what changed (such as
   **1 document changed**), shows a short note on what the agent changed, then each part of the definition:
   **Simulation prompt** and **Expected outcomes** for a scenario, **Test plan** for a test. A part the draft
   leaves alone is marked **No changes**.

3. Click **Show changes** to see what changed: added words in green, removed words struck through.
   **Hide changes** shows the new text again.

4. Click **Save changes** to keep the draft. **Discard** closes the dialog and leaves the definition as it was.
   **Back to instruction** takes you back to **What should change?**.

   **You should see:** the new definition on the **Definition** tab, under the agent's note and "Saved just now".

Always say in **What should change?** what you want. Then read the draft before you save it.

## Fix with AI

A test that can't run says **Can't run** at the top of its **Definition** tab, with **Fix with AI** and
**Edit it myself**.

1. Click **Fix with AI**.

   **You should see:** **Improve with AI**, with **What should change?** already filled in with why the test
   can't run: "Pre-filled from why it can't compile. The rewrite opens as an unsaved change for you to check and
   save."

2. Click **Improve definition**.

   **You should see:** the rewritten definition on the **Definition** tab, not saved yet, with **Cancel** and
   **Save** above it.

3. Read it, then click **Save**.

   **You should see:** "Saved just now", and **Can't run** is gone.

## Lock

TrustAI turns a scenario or test into instructions before it runs. [Locking](https://docs.provar.dev/glossary.md#lock) keeps it as it is.

* **Scenario:** the lock button's name says what it does: "Lock this scenario: no edits to its definition, and
  runs use its compiled instructions exactly as they are". Click it.

  **You should see:** the message **Scenario locked**, **Locked** beside the run count, and a lock mark on its row
  in the list. Editing and **Improve with AI** are switched off.

* **Test:** the button is named "Lock this test to freeze its definition and stop saving repairs forward." Click
  it.

  **You should see:** after a short wait (up to about 20 seconds in our check), the message **Test locked** and **Locked** beside the run count.

To unlock, click the same button again ("Unlock this scenario so its definition can be edited", or "Unlock this
test to edit it and save repairs forward."). Locked doesn't mean passed.

## If something goes wrong

| What you see | What to do |
| - | - |
| **Nothing was saved**: "The AI's answer wasn't a usable test. Generate again." | Write what should change in **What should change?** and try again. |
| You can't edit a scenario or test, and **Improve with AI** does nothing | It's locked. Click the lock button to unlock it. |
| **Improve definition** can't be clicked | Type what should change in **What should change?** first. |
| A note says you have an unsaved draft, such as "1 unsaved scenario draft" | Drafts only you can see wait on the **Scenarios** or **Tests** page. A draft TrustAI wrote is kept even if you close **New scenario** without saving it. Click **Review** on the note (it shows how many, such as **Review 1 draft**) to save it. A draft can't run or count toward [coverage](https://docs.provar.dev/glossary.md#coverage) until you save it. If you don't see the note, reload the page. |

## Next

* [Run tests and read results](https://docs.provar.dev/guides/beginner/run-tests-and-read-results.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.