> For the complete documentation index, see [llms.txt](https://learning.contextqa.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learning.contextqa.com/ai-features/generate-tests-from-requirements-tutorial.md).

# Tutorial: Generate Tests from Requirements

{% hint style="info" %}
**Who is this for?** QA managers, SDETs, and agile teams who maintain requirements in documents or tickets and want a complete test suite generated from them — with each test traceable back to the requirement it covers.
{% endhint %}

ContextQA reads a requirements artifact — a specification document, a user story, or a set of acceptance criteria — and generates a complete set of test cases from it. Instead of translating each requirement into steps by hand, you upload the source, answer a few clarifying questions, and review the test cases the AI produces. Every generated case maps back to a requirement, so you can show coverage at a glance.

In this tutorial you:

1. Start an import from a requirements document
2. Configure the target platform, publish mode, and suite creation
3. Let ContextQA analyze the requirements and answer its clarifying questions
4. Review the generated test cases and approve the ones you want
5. Run a generated test and confirm it works

**End result:** A reviewed test suite generated from a requirements document, with each test case traceable to the requirement that produced it — ready to run as part of your regression cycle.

## Prerequisites

* A ContextQA account with at least one workspace ([sign up](https://accounts.contextqa.com/onboard))
* A requirements document to import — a `.pdf`, `.docx`, `.xlsx`, `.csv`, or `.txt` file describing the behavior you want to test
* The URL of the web application the requirements describe
* Familiarity with [core concepts](/getting-started/core-concepts.md) — specifically test cases, suites, and test plans

If you don't have a requirements document handy, create a plain text file named `registration-requirements.txt` with the following content and use it throughout this tutorial:

```
User Registration Requirements

1. The registration form collects first name, last name, email address, and password.
2. Email addresses must be unique across all accounts.
3. Passwords must be at least 8 characters and contain one uppercase letter,
   one lowercase letter, and one number.
4. On successful registration, the user is redirected to the dashboard.
5. If the email is already in use, an inline error appears next to the email field.
6. If the password does not meet the rules, an inline error appears next to the
   password field.
```

***

## Step 1: Start a requirements import

Begin by opening the test case creation panel and choosing the import path.

1. In the left sidebar, select **Test Cases**.
2. Click the **+** icon to open the creation panel. A full-height panel slides in from the right.
3. On the method selection screen, click **Import File**.
4. The panel asks *What type of file would you like to import?* Select the **Import Requirements** card.

**Verify it worked:** The panel switches to a stepper with three steps — **Inputs**, **Analysis**, and **Clarifications** — with **Inputs** active.

{% hint style="info" %}
**Tip:** **Import Requirements** generates test cases from a specification. The other card, **Import Test Cases**, is for a different task — migrating an existing test library from an Excel spreadsheet where the steps are already written.
{% endhint %}

***

## Step 2: Configure the import

On the **Inputs** step, set how ContextQA generates and publishes the test cases before you upload the file.

1. Click **Show Configuration Options** to expand the settings.
2. Under **Select Target Platform**, choose **Web Application**.
3. Under **Publish Mode**, choose **Require Approval**. Generated test cases stay in a draft state until you review them, which is the right choice while you learn the workflow.
4. *(Optional)* Add context that helps the AI generate more accurate cases:

| Field                      | Example value                                                                               |
| -------------------------- | ------------------------------------------------------------------------------------------- |
| **Name**                   | `User registration requirements`                                                            |
| **Additional information** | `Web app at https://yourapp.com/register. Email and password are the only required fields.` |

{% hint style="info" %}
**Tip:** Attach UI mockups or screenshots alongside the document. Visual context helps the AI generate more relevant and complete test cases.
{% endhint %}

5. Upload your requirements file. You can add up to 10 files per import — documents (`.pdf`, `.docx`, `.xlsx`, `.csv`, `.txt`), images, or video recordings.
6. Continue to the next step.

**Verify it worked:** The stepper advances to **Analysis** and ContextQA begins reading the document.

{% hint style="info" %}
**Note:** **Require Approval** keeps the generated test cases as drafts until you approve them. **Auto Publish** publishes them immediately and lets you also create a test suite, create a test plan, and run the plan as part of the same import. Use **Auto Publish** once you trust the generation quality for a given source.
{% endhint %}

***

## Step 3: Review the analysis and answer clarifications

ContextQA reads the document, extracts the testable requirements, and then asks about anything ambiguous.

1. On the **Analysis** step, ContextQA lists the requirements it identified from your document. Confirm the list reflects the behavior you want covered.
2. The flow advances to the **Clarifications** step. The AI presents follow-up questions about details the document left open — for example, *What's the exact wording of the duplicate-email error?* or *What URL should the registration test start from?*
3. Answer each question in its field. Specific answers produce more accurate tests. If a question doesn't apply, leave it blank.
4. Submit your answers to start generation. If you have no answers to add, skip the questions instead — generation still runs.

**Verify it worked:** ContextQA generates a set of test cases covering the requirements and their failure modes. For the registration example, it produces cases for successful registration, the duplicate-email error, and each password validation rule.

{% hint style="info" %}
**Why clarifications matter:** Generation quality tracks input quality. A requirement that says "passwords must be strong" produces a vague test; answering the clarification with "at least 8 characters, one uppercase, one lowercase, one number" produces a precise one. The more explicitly you describe expected behavior, the better the generated tests.
{% endhint %}

***

## Step 4: Review and approve the generated test cases

Generated cases from a requirements import appear under the uploaded file so you can review coverage in one place.

1. In the left sidebar, go to **Assets → Requirements**. Your imported file appears in the list with a **Status** of **Completed** and a count of generated test cases.
2. Click the file row to open its detail view. The **Test Cases** tab lists every generated case.
3. Review the table. Each row shows:

| Column        | What it tells you                                                                                                   |
| ------------- | ------------------------------------------------------------------------------------------------------------------- |
| **Test Case** | The name and an inline description — click to open the detail drawer                                                |
| **Type**      | The test type — `Positive`, `Functional`, `Negative`, `Edge`, `Field Validation`, `End to End`, or `Boundary Value` |
| **Status**    | Whether the case is **New** or matches an **Existing** test                                                         |
| **Decision**  | **Pending**, **Approved**, or **Rejected**                                                                          |

4. Click any test case to open the detail drawer and inspect its steps, expected results, and variables.
5. For each case you want to keep, click **Approve**. To discard one, click **Reject**. To send an approved or rejected case back for another look, use **Revert to Review**.

**Verify it worked:** The test cases you approved move to an **Approved** decision and are published to your test case list. Because you chose **Require Approval** in Step 2, only the cases you approved are published.

{% hint style="info" %}
**Tip:** Open the **Gaps** tab in the file detail view to see requirements the generated suite doesn't yet cover. Address gaps by adding context and regenerating. See [Requirements coverage gaps](/ai-features/requirements-coverage-gaps.md).
{% endhint %}

***

## Step 5: Run a generated test

Confirm a generated test works against your live application.

1. Open one of the approved test cases — for example, *Registration — successful sign-up*.
2. Review the steps. The AI fills in the starting URL, the form interactions, and the assertions from your requirement and clarification answers. Edit any step whose wording doesn't match your application's exact labels.
3. Click **Run** in the top toolbar.
4. Select an execution environment and start the run.

**Verify it worked:** The execution viewer shows each step with a real-time pass/fail indicator. When the run finishes, click **View Detailed Report** to see the step-by-step breakdown, screenshots, and video.

{% hint style="warning" %}
**Common mistake:** If a step fails because a button or field label doesn't match, the requirement described the behavior in different words than your application uses. Edit the step to use the exact label, or add a [Knowledge Base](/ai-features/knowledge-base.md) entry so future generations use your application's real terminology.
{% endhint %}

***

## Summary

You generated a test suite from a requirements document in five steps:

1. **Started a requirements import** from the test case creation panel
2. **Configured** the target platform, publish mode, and context for generation
3. **Reviewed the AI analysis** and answered clarifying questions to sharpen the output
4. **Approved** the generated test cases, each traceable to the requirement that produced it
5. **Ran** a generated test and reviewed the evidence

A specification that existed only as a document is now a reviewed, runnable test suite.

## Next steps

* **Generate from a Jira ticket:** If you manage requirements in Jira, the same flow can pull test cases from ticket descriptions and acceptance criteria. See [Jira integration](/integrations/jira.md) and [AI test generation](/ai-features/ai-test-generation.md#2-from-jira--azure-devops-tickets).
* **Close coverage gaps:** Use the **Gaps** tab to find requirements without a test, then add context and regenerate. See [Requirements coverage gaps](/ai-features/requirements-coverage-gaps.md).
* **Improve accuracy with application context:** Add a [Knowledge Base](/ai-features/knowledge-base.md) so the AI knows your login flow, navigation, and terminology before it generates.
* **Organize and schedule:** Add the approved cases to a suite and schedule them. See [Managing test suites](/web-testing/managing-test-suites.md) and [Tutorial: Build and schedule a regression suite](/execution/regression-suite-tutorial.md).
* **Run on every change:** Trigger the suite from your pipeline. See [GitHub Actions](/integrations/github-actions.md) or [Tutorial: CI/CD with GitHub Actions](/getting-started/ci-cd-tutorial.md).

## Related pages

* [AI test generation](/ai-features/ai-test-generation.md) — every generation source, including requirements, Jira, Figma, OpenAPI, and video
* [Creating test cases](/web-testing/creating-test-cases.md) — all four creation methods in the unified panel
* [Uploaded test files](/web-testing/uploaded-test-files.md) — manage imported files and their generated test cases
* [Requirements coverage gaps](/ai-features/requirements-coverage-gaps.md) — find and close gaps in generated coverage
* [Knowledge Base](/ai-features/knowledge-base.md) — give the AI application context for more accurate generation

{% hint style="info" %}
**Turn your requirements into tests — no code required.** [**Start Free Trial →**](https://app.contextqa.com/register) — Or [**Book a Demo →**](https://contextqa.com/book-a-demo/) to see ContextQA generate a suite from your specifications.
{% endhint %}


---

# 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://learning.contextqa.com/ai-features/generate-tests-from-requirements-tutorial.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.
