# Generate tests for requirement

> Generate manual test cases from a requirement in Test Manager using Autopilot, with guidance on Context Grounding, prompt instructions, and reviewing or regenerating results.

:::note
Feature availability depends on the cloud platform you use. For details, refer to the [Test Manager feature availability page](https://docs.uipath.com/test-manager/automation-cloud/latest/user-guide/test-manager-feature-availability-page).
:::

Use Autopilot to generate manual test cases directly from a requirement. Autopilot analyzes the requirement's name, description, attachments, custom fields, labels, and documents to create a list of test cases you can review, refine, and add to your project. For guidance on writing a requirement that produces accurate tests, refer to [Best practices and limitations](https://docs.uipath.com/autopilot/other/latest/user-guide/autopilot-for-testers-best-practices#manual-test-generation).

## Prerequisites

* Your Test Manager role must have the following permissions:
  * **Test Case** - Create
  * **Requirement** - Edit
* (Cloud Commercial only) To use Retrieval-Augmented Generation (RAG) when generating tests, set up Context Grounding first. For details, refer to [Context Grounding best practices](https://docs.uipath.com/automation-cloud/automation-cloud/latest/admin-guide/context-grounding-best-practices).

## Generate tests for a requirement

1. Open a project and go to **Requirements**.
2. Open the requirement to generate tests for, or create one with a detailed description.
3. Select **Optimize coverage**.
4. In the **Optimize coverage** dialog, select **Generate tests**.
5. In the **Add documents** section of the **Provide additional context** window, select the requirement's attachments to use for generation, or upload additional files.
6. (Cloud Commercial only) In the **Leverage RAG** section, select an index that stores data uploaded to [Context Grounding](https://docs.uipath.com/automation-cloud/automation-cloud/latest/admin-guide/about-context-grounding). Autopilot uses the indexed content as extra context when a requirement document is incomplete or references details stored elsewhere.
   1. From the **Select folder** dropdown, select the folder that contains the index.
   2. From the **Select index** dropdown, select the index to reference.
   3. In **Number of results**, enter the number of tests to generate from the referenced information.

   :::tip
   For best practices on working with Context Grounding, refer to [Context Grounding best practices](https://docs.uipath.com/automation-cloud/automation-cloud/latest/admin-guide/context-grounding-best-practices).
   :::
   
7. Select **Next**, then use the **Provide additional guidance** window, or choose a prompt from the [Prompt library](https://docs.uipath.com/test-manager/automation-cloud/latest/user-guide/prompt-libraries#predefined-prompts), to instruct Autopilot to:
   * Cover all user steps and acceptance criteria described in the requirement.
   * Generate pre-conditions.
   * Generate an expected result for each test step.
   * Disregard existing tests linked to the requirement. By default, Autopilot considers linked tests to avoid duplicating them.

   Autopilot can generate a maximum of 50 test cases at a time (10 by default), each with a maximum of 50 steps. Refer to [Best practices and limitations](https://docs.uipath.com/autopilot/other/latest/user-guide/autopilot-for-testers-best-practices#manual-test-generation) for guidance on choosing an effective count and structuring test steps.
8. Select **Generate tests** to start the process. When generation finishes, you receive a **Test Case generation completed** notification, in-app or by email depending on your [notification preferences](https://docs.uipath.com/test-manager/automation-cloud/latest/user-guide/my-notifications#subscribing-to-events).
9. Select the notification to review the generated test cases.
   1. Expand each test case in the **Generate tests** panel and review its content.
   2. If you're satisfied, select **Create tests**. Created test cases display a checkmark and are linked to the source requirement.
10. If you're not satisfied with the results, select **Regenerate** and refine the input:
    1. Attach more relevant documents for Autopilot to use.
    2. Select **Next** and enter additional details in the **Provide instructions** box.
    3. Select **Regenerate**.
    4. Select the **Test generation completed** notification to access the regenerated test cases.
    5. Expand and review each test case, then select **Create tests** for the ones to keep.

## Supported file types

You can provide the following file types to Autopilot as supporting documents:

* Processes only text content – TXT, BPMN, CSV
* Processes both text and image content – DOCX, XLSX, PNG, JPG, PDF

## Result

Autopilot creates the generated test cases in the **Test Cases** section of your project and links them to the source requirement used to generate them. A **Test Case generation completed** notification confirms the creation.
