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

# Plan Generation & Editing

> How TestSprite turns discovered endpoints into a structured test plan, and how to review, prune, refine, and add to it before generation runs.

<Frame>
  <img src="https://mintcdn.com/testspriteinc/TFcog-WNvgZBB09l/images/api-testing-plan-edit-overview.png?fit=max&auto=format&n=TFcog-WNvgZBB09l&q=85&s=12e1b2a2c71c49a8654131f06ff60a80" alt="API plan review with tests grouped by category" width="1600" height="952" data-path="images/api-testing-plan-edit-overview.png" />
</Frame>

## What Plan Generation Does

For every endpoint that survived [API Discovery](/web-portal/core/api/api-discovery), TestSprite's testing agent produces a **structured plan**: test cases grouped by use case, each with a title, description, expected behavior, and priority. You can read, edit, prune, and add to the plan **before** any tests are generated, which is the cheapest place to catch a misunderstanding.

<Card>
  ```mermaid theme={null}
  flowchart LR
      A[Endpoints known<br/>from API Discovery] --> M[Feature map<br/>features · use cases] --> B[Plan Generation]
      B --> C[Structured plan<br/>use case · title · description<br/>expected behavior · priority]
      C --> D{Your review<br/>edit · prune · add}
      D -->|Run all| E[Runnable tests]
  ```
</Card>

<Info>
  **Nothing executes during plan generation.** No HTTP calls are made to your API at this step.
</Info>

## What Goes Into the Plan

| Input | Where it comes from | What plan generation does with it |
| :- | :- | :- |
| <kbd>Feature map</kbd> | [Test Coverage](/web-portal/core/working-with-test/coverage-map) | Groups and scopes the tests by use case |
| <kbd>Discovered endpoints</kbd> | [API Discovery](/web-portal/core/api/api-discovery) | One sub-plan per endpoint, with shape-appropriate tests |
| <kbd>PRD / docs upload</kbd> | New Project form | Anchors the description and asserted behavior in what the endpoint is *for* |
| <kbd>Response shapes from discovery</kbd> | Discovery phase | Used as ground truth, so tests reference real field names |
| <kbd>Extra Instructions</kbd> | New Project form | "Skip the admin endpoints", "Always assert response time \< 200ms"; these get woven in |

## The Plan Structure

Each endpoint gets a **sub-plan** covering the categories of tests that fit what it does. Common ones:

<Frame>
  <img src="https://mintcdn.com/testspriteinc/NgwJ2RcRMRwjh7Vv/images/plangen-type.png?fit=max&auto=format&n=NgwJ2RcRMRwjh7Vv&q=85&s=a190de93d34cdc85b2e806020b032799" alt="API plan with category groupings" width="1600" height="538" data-path="images/plangen-type.png" />
</Frame>

* **Functional / happy path**: valid inputs, expected response shape, basic error paths (404, 400 on bad input)
* **Authorization & authentication**: unauthenticated → 401, wrong-user → 403, ownership checks, token handling, signature tampering
* **Error handling & edge cases**: missing required fields, malformed input, type coercion traps, unicode / null / encoding edges
* **Boundary & load**: oversized payloads, max array lengths, rate-limit edges, concurrent-write contention
* **Security probes**: privilege escalation, common attack patterns relevant to the endpoint

Not every category applies to every endpoint. A small CRUD endpoint might get 3–8 tests; a complex endpoint with security implications can get 15+.

## Reviewing the Plan

Click <kbd>Plan Tests</kbd> on **Test Coverage** and TestSprite's testing agent plans the tests. They open in **Review proposed tests**, grouped by use case; pick a use case on the left to see its tests.

<Steps>
  <Step title="Pick a use case to see the tests in it">
    Each row shows the test title and a short description. Click the row body to expand it.

    <Frame>
      <img src="https://mintcdn.com/testspriteinc/ReL5WaX10_vGG0UW/images/plangen-category.png?fit=max&auto=format&n=ReL5WaX10_vGG0UW&q=85&s=2a1d6ff30d90fcea27725386c780f2fd" alt="API plan review with category groupings" width="3284" height="1228" data-path="images/plangen-category.png" />
    </Frame>
  </Step>

  <Step title="Untick anything you don't want">
    The checkbox on each row controls whether the test is generated. A use case's **Select All** checkbox toggles all of its tests.

    <Frame>
      <img src="https://mintcdn.com/testspriteinc/ReL5WaX10_vGG0UW/images/plangen-deselect.png?fit=max&auto=format&n=ReL5WaX10_vGG0UW&q=85&s=dbda04a9be83adb366165af4fbed1310" alt="API plan review with category groupings" width="3284" height="972" data-path="images/plangen-deselect.png" />
    </Frame>
  </Step>

  <Step title="Edit titles and descriptions in place">
    Click the title to rename it, or the description to edit it. Your edits shape the generated test.

    <Frame>
      <img src="https://mintcdn.com/testspriteinc/ReL5WaX10_vGG0UW/images/plangen-edit.png?fit=max&auto=format&n=ReL5WaX10_vGG0UW&q=85&s=84ddc449db5bc2b1c95fa6a9d1c586ac" alt="API plan review with category groupings" width="3284" height="996" data-path="images/plangen-edit.png" />
    </Frame>
  </Step>

  <Step title="Reorder by priority if you want">
    Each test has a priority, and higher-priority tests run first. Reorder if there's a flow you want verified before everything else.

    <Frame>
      <img src="https://mintcdn.com/testspriteinc/ReL5WaX10_vGG0UW/images/plangen-priority.png?fit=max&auto=format&n=ReL5WaX10_vGG0UW&q=85&s=78bcc5b9e30adcc693c1288edb65bf05" alt="API plan review with category groupings" width="3284" height="856" data-path="images/plangen-priority.png" />
    </Frame>
  </Step>
</Steps>

<Tip>
  On a first run, keeping everything selected is usually right. If a use case has more tests than you want, untick individual low-value ones rather than the whole use case.
</Tip>

## Adding Tests in Natural Language

Click <kbd>+ More Test Case for \<use case></kbd> below the list to add a blank row, then write its name and description in natural language. TestSprite generates the test from what you write. Added rows work like the others: you can edit, prune, or reorder them.

<Frame>
  <img src="https://mintcdn.com/testspriteinc/TFcog-WNvgZBB09l/images/api-testing-plan-edit-add-manually.png?fit=max&auto=format&n=TFcog-WNvgZBB09l&q=85&s=7005c51071b84c8c17f97f792cbde7da" alt="A Custom test row with empty name and description, added via + More Test Case" width="1600" height="540" data-path="images/api-testing-plan-edit-add-manually.png" />
</Frame>

<CodeGroup>
  ```text Targeted addition theme={null}
  POST /orders with quantity=0 is rejected with a 400.
  ```

  ```text Domain-specific edge theme={null}
  POST /users with an email already used by another user returns 409 Conflict, not 200.
  ```
</CodeGroup>

## What "Run all" Actually Triggers

Clicking **Run all** (or **Run N tests**) adds the selected tests and starts generating and running them. The plan is locked in at that point; later edits require regenerating. Next: [Endpoint Tests](/web-portal/core/api/endpoint-tests).

## When Plan Generation Looks Wrong

<AccordionGroup>
  <Accordion title="A test asserts on a field that doesn't exist">
    Discovery didn't fully observe this endpoint's response, so the shape was inferred from your docs. Correct the test description to match the real shape, and generation will follow your edit.
  </Accordion>

  <Accordion title="An obvious test wasn't generated">
    Either the endpoint wasn't in the discovered set ([revisit Discovery](/web-portal/core/api/api-discovery)), or the test was judged redundant or out of scope. Add it yourself with <kbd>+ More Test Case</kbd>.
  </Accordion>

  <Accordion title="Tests are too generic — they don't reflect our domain">
    Give more domain context in **Extra Instructions** (in **Project Settings → General**) or a richer PRD, e.g. "orders have a status enum: pending, confirmed, shipped, delivered, cancelled".
  </Accordion>

  <Accordion title="The Security category is overkill for an internal-only API">
    Untick the security tests in the review. The default sizing assumes external exposure; for internal services 1–2 auth checks are usually enough.
  </Accordion>

  <Accordion title="Plan generation returned 0 tests for an endpoint">
    The endpoint was discovered but judged unsafe to test (missing auth pattern, unclear response shape). Add the test yourself with <kbd>+ More Test Case</kbd>.
  </Accordion>
</AccordionGroup>

## Where to Go Next

<Columns cols={2}>
  <Card title="Endpoint Tests" href="/web-portal/core/api/endpoint-tests" icon="cube">
    The next phase: turn the plan into runnable tests
  </Card>

  <Card title="Integration Tests Generation" href="/web-portal/core/api/integration-tests" icon="link">
    Auto-assembled multi-step chains
  </Card>

  <Card title="Managing Test Cases" href="/web-portal/core/working-with-test/managing-test-cases" icon="pen">
    Natural-language refinement after tests are generated
  </Card>
</Columns>


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