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

# Testing workflows

> Catch regressions before your users do — define test cases with expected outputs, run them on demand, and track pass/fail over time

## Why test a workflow?

Agent workflows are deceptively easy to break. A prompt tweak that looks harmless can shift a classification, a new tool can widen the output, a schema change upstream can silently reshape inputs. Without tests, you find out when a customer does.

MagOneAI lets you capture real-world examples — input plus the output you expect — and replay them any time. Before publishing, before rolling out a prompt change, before a demo, you can run the full suite and see which cases still pass.

## What a test case looks like

Each test case belongs to a specific use case and captures three things:

* **Input** — the same payload you'd send when executing the workflow normally
* **Expected output** — what a correct run should produce (optional)
* **Assertion mode** — how strictly to compare the actual output against the expected output

Test cases live alongside the workflow in Studio, under the use case's **Test Cases** section. You can add, edit, and delete them freely without affecting the workflow itself.

## Assertion modes

Not every workflow should be checked the same way. MagOneAI offers three modes so you can pick the right level of strictness per test case:

<CardGroup cols={3}>
  <Card title="None" icon="circle-check">
    Passes if the workflow runs to completion without error. Use when the output varies (free-form text) but you still want to catch crashes or timeouts.
  </Card>

  <Card title="Contains" icon="layer-group">
    Passes if every key in your expected output appears in the actual output with a matching value. Extra keys are fine. Use when only some fields are deterministic.
  </Card>

  <Card title="Exact" icon="equals">
    Passes only if the actual output deep-equals the expected output. Use for structured outputs where every field is predictable.
  </Card>
</CardGroup>

<Tip>
  Start permissive and tighten over time. `None` for early exploration, `Contains` for most regression tests, `Exact` only where you truly expect identical output every run.
</Tip>

## Running test cases

<Steps>
  <Step title="Create a test case">
    Open the use case in Studio, go to **Test Cases**, and fill in the input and expected output. Pick an assertion mode that matches what you actually want to verify.
  </Step>

  <Step title="Run one, or run the whole suite">
    Hit **Run** on a single test case, or **Run all** to execute every test case in sequence. Each run spawns a real workflow execution against the current workflow.
  </Step>

  <Step title="Review the result">
    Each test case shows its latest status — **Passed**, **Failed**, or **Not run** — alongside the execution ID so you can drill into logs.
  </Step>

  <Step title="Inspect mismatches on failures">
    For `Contains` and `Exact` modes, failed tests show exactly which fields didn't match. Expected vs. actual is displayed side by side.
  </Step>

  <Step title="Download a report">
    Export the suite's latest results as a report to share with reviewers or attach to a release.
  </Step>
</Steps>

### Tests that involve human tasks

If your workflow pauses on a **Human Task** node, the test run pauses too — just like a real execution. Respond to the task inline from the test panel and the run resumes automatically. This lets you test end-to-end flows without mocking the human step.

## Generating test cases with AI

Writing test cases by hand can be the slowest part of testing, especially for workflows with rich input schemas. MagOneAI can generate a starter suite for you by reading the workflow definition, the agents it uses, and any existing test cases.

<Steps>
  <Step title="Open Generate with AI">
    From the Test Cases section, open the generation panel and pick which model to use.
  </Step>

  <Step title="Review suggestions">
    The AI proposes a set of test cases — each with a descriptive name, realistic input matching the START activity's input schema, and a reasonable expected output.
  </Step>

  <Step title="Select and save">
    Tick the ones you want to keep. Edit any of them before or after saving — generation is a starting point, not a final answer.
  </Step>
</Steps>

<Info>
  AI-generated suggestions respect your workflow's input schema and existing test cases, so they tend to cover edge cases you haven't written yourself rather than duplicating what's already there.
</Info>

## How test cases fit into your process

A few ways teams use testing effectively:

* **Before publishing.** Run the full suite against your latest draft. If anything fails, fix before publishing the revision.
* **After a prompt change.** Re-run tests to see if the change shifted behavior on cases you already captured.
* **When bugs are reported.** Turn the failing input into a new test case. Once fixed, the test ensures the bug stays fixed.
* **For regression reports.** Download the latest suite report as evidence that a release meets your quality bar.

<Warning>
  Test cases run the **current workflow** — not a frozen snapshot. Combined with [versions and publishing](/workflows/versions-and-publishing), you can iterate on a draft, run tests against it, and only publish once the suite is green.
</Warning>

## Next steps

<CardGroup cols={2}>
  <Card title="Versions & publishing" icon="code-branch" href="/workflows/versions-and-publishing">
    Pair testing with versioning so you never publish a regression
  </Card>

  <Card title="Workflow overview" icon="diagram-project" href="/workflows/overview">
    Back to activities, the canvas, and workflow basics
  </Card>
</CardGroup>
