# Generate tests for SAP transactions

> Generate, review, and refine manual test cases for SAP transactions with Autopilot from the Heatmap or the Change Impact Analysis report.

You can generate manual test cases for SAP transactions either from the **Heatmap** for SAP or from the transactions listed in the **Change Impact Analysis** for SAP report.

You can guide Autopilot by providing additional instructions to focus on specific aspects when generating manual test cases.

![docs image](https://dev-assets.cms.uipath.com/assets/images/autopilot/autopilot-docs-image-426277-0ce68400-94dac951.webp)

Additionally, you can provide supporting documents with more information about the requirement or SAP transaction to enable Autopilot to generate more accurate and useful manual test cases.

After generating manual test cases with **Generate tests**, review the generated test cases. Then, either create the desired test cases with **Create tests** or refine them using **Regenerate tests**.

:::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).
:::

## Prerequisites

* To generate tests from Change Impact Analysis, your Test Manager role must have **Test Case** - Create permission.
* To generate tests from the Heatmap, your Test Manager role must have **Test Case** - Create permission.
* (Cloud Commercial only) To leverage RAG (Retrieval-Augmented Generation) when generating tests, set up Context Grounding first, as RAG is a component of Context Grounding. For more information, refer to [Best practices](https://docs.uipath.com/automation-cloud/automation-cloud/latest/admin-guide/context-grounding-best-practices).
* Consider the file types Autopilot can process. Depending on the file type, Autopilot can process certain content from it:
  * Processes only text content – TXT, BPMN, CSV
  * Processes both text and image content – DOCX, XLSX, PNG, JPG, PDF

## Steps

1. Open the **Generate tests** flow for the transaction you want to cover:
   * **From Change Impact Analysis**: In the **Analyze Transports** step, select **List view** to switch to a table of the impacted transactions. For a transaction marked **GAP**, select **Generate**.
   * **From Heatmap**: Select a transaction from the Heatmap, then select **Generate tests**.

   The **Provide additional context** window opens, focused on the **Add documents** section, prompting you for attachments or other documents necessary for generating test cases.

   :::note
   If you are using an RFC (Remote Function Call) connection in Change Impact Analysis, you can only generate tests from the **UI** view tab.
   :::

2. In the **Add documents** section, select additional attachments to use when generating tests, or upload other files yourself.

   If using Cloud Commercial, you can also leverage RAG through Context Grounding:
   1. In the **Leverage RAG** section of the **Provide additional context** window, select an index that stores your data uploaded to [Context Grounding](https://docs.uipath.com/automation-cloud/automation-cloud/latest/admin-guide/about-context-grounding). The selected index helps Autopilot generate more accurate tests by giving it context about the applications you are automating. For example, use RAG when a requirement document has incomplete information or refers to details covered in other sections.
   2. From the **Select folder** dropdown list, select the folder containing the indexes you want to share with Autopilot.
   3. From the **Select index** dropdown list, select the specific index you want Autopilot to reference.
   4. For **Number of results**, enter the number of tests you want Autopilot to generate based on the referenced information.
3. Select **Next**.
4. Choose a prompt from the [Prompt library](https://docs.uipath.com/test-manager/automation-cloud/latest/user-guide/prompt-libraries#predefined-prompts), or enter instructions directly in the **Provide additional guidance** window. Autopilot can follow instructions such as:
   * Cover all user steps and acceptance criteria described in the requirement.
   * Generate pre-conditions for each test case.
   * Generate an expected result for each test step.
   * Disregard existing tests already linked to a requirement. By default, Autopilot considers linked tests to avoid generating duplicates.

   Maximum test cases per generation: 50
5. Optionally, from the **Model** dropdown list, select the AI model that Autopilot should use.
6. Select **Generate tests** to start the process. When generation finishes, you receive a **Test Case generation completed** notification. Depending on your [notification preferences](https://docs.uipath.com/test-manager/automation-cloud/latest/user-guide/my-notifications#subscribing-to-events), you receive the notification in-app, by email, or both.
7. Select the notification to review the generated test cases. Expand each test case in the **Generate tests** panel and review its content.
8. Review the results:
   * If you are satisfied with the generated test cases, select the ones you want to keep, then select **Create tests**.
   * If you are not satisfied with the generated test cases, refine the generation:
     1. Select **Regenerate tests**.
     2. Attach more relevant documents for Autopilot to use.
     3. Select **Next** and enter additional details in the **Provide instructions** box.
     4. Select **Regenerate tests** to apply the refinements.
     5. Select the **Test generation completed** notification to access the regenerated test cases.
     6. Expand each regenerated test case and select the ones you are satisfied with.
     7. Select **Create tests**.

:::note
Test cases generated from the Heatmap are labeled `autopilot-generated` and `TRAN:<transactionCode>`, where `<transactionCode>` is the SAP code of the source transaction.
:::
