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

# Agentic testing

> How Momentic's agents help author, repair, and maintain tests.

Agentic testing uses AI agents across the test lifecycle: an agent drives a flow
from a natural-language goal, repairs tests when the UI changes, and proposes
new tests as the product changes. Reach for it when keeping a hand-written test
suite in sync with a changing product takes more effort than it is worth.

An agentic step takes a goal and a post-condition. The agent drives the flow and
the assertion verifies the outcome:

```yaml checkout.test.yaml theme={null}
fileType: momentic/test/v2
id: checkout-happy-path
steps:
  - act:
      goal: Add an item to the cart and complete checkout as a guest.
      postcondition: An order confirmation number is visible.
```

## When to use it

* Your UI changes often enough that hard-coded selectors break constantly.
* A flow's exact steps are not predictable ahead of time: they vary by feature
  flag, A/B test, or user state.
* You want coverage to stay current as the product changes without hand-writing
  a test for every change.

## Step-based vs agentic

This is the main decision, and it is per step, not per test suite. Most tests
should stay step-based; reach for an agentic step only where a fixed script does
not fit.

|             | Step-based                        | Agentic                               |
| ----------- | --------------------------------- | ------------------------------------- |
| Speed       | Fast                              | Slower, the agent reasons each run    |
| Determinism | Repeatable                        | Non-deterministic                     |
| Best for    | Critical paths you assert tightly | Flows whose steps are not predictable |

Keep critical paths step-based so they are fast and you can assert exact
outcomes. Use agentic steps for the parts that genuinely vary, and wrap each one
in an assertion so the outcome is still checked. See
[agentic testing](/core-concepts/agentic-testing) for the full trade-offs.

## Where agents help across the lifecycle

* **Authoring**: write a goal as an [AI action](/core-concepts/agentic-testing)
  step, or run the [explore agent](/ai/explore) to read a diff and draft tests
  for the journeys it changed. Give agents reusable context with a
  [knowledge base](/ai/knowledge-base) so they use your terminology and flows.
* **Repair**: [auto-heal](/reliability/auto-heal) fixes a test mid-run when the
  UI changed, so a moved or renamed element does not fail a test that still
  works.
* **Maintaining coverage**: run the [explore agent](/ai/explore) on each pull
  request to surface changed journeys and propose tests for the gaps. See
  [PR testing](/guides/use-cases/pr-testing).

## Keep it trustworthy

Agentic steps are flexible but non-deterministic. Constrain them so a run stays
trustworthy:

* Wrap each agentic step in an explicit assertion so a run verifies the outcome,
  not just that the agent finished.
* Keep goals short and specific. "Sign up a new user with a fresh email" works
  better than "test the onboarding flow."
* Pass anything the agent cannot infer (invite codes, IDs) via
  [variables](/core-concepts/variables).

## Get started

<Steps>
  <Step title="Write your first agentic step">
    Add an AI action step with a goal and a post-condition. See [agentic
    testing](/core-concepts/agentic-testing).
  </Step>

  <Step title="Let auto-heal maintain it">
    [Auto-heal](/reliability/auto-heal) repairs the test when the UI changes, so
    routine edits do not break it.
  </Step>

  <Step title="Let the explore agent fill gaps">
    Run [`momentic ai explore`](/ai/explore) against a diff to find and draft
    tests for changed journeys.
  </Step>
</Steps>

## Related

<CardGroup cols={2}>
  <Card title="Agentic testing" icon="robot" href="/core-concepts/agentic-testing">
    AI action steps and when to use a goal instead of fixed steps.
  </Card>

  <Card title="Explore agent" icon="compass" href="/ai/explore">
    Discover changed journeys and author tests from a diff.
  </Card>

  <Card title="Auto-healing" icon="wrench" href="/reliability/auto-heal">
    Repair tests when the UI changes.
  </Card>

  <Card title="Knowledge base" icon="brain" href="/ai/knowledge-base">
    Give agents reusable context about your product.
  </Card>
</CardGroup>
