> For the complete documentation index, see [llms.txt](https://docs.understand.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.understand.tech/documentation/apps/tcg-test-case-generator/user-portal/script-generation.md).

# Script generation

Script Generation converts a test case into an executable automation script in your chosen language and framework. The script includes test steps, assertions, and the scaffolding needed to run it directly

{% hint style="info" %}
This feature must be enabled by your admin in Test Case Settings.
{% endhint %}

***

## Supported languages and frameworks

<table><thead><tr><th width="326.9259033203125">Language</th><th>Framework</th></tr></thead><tbody><tr><td>Python</td><td>pytest</td></tr><tr><td>Python</td><td>unittest</td></tr><tr><td>Python</td><td>Robot Framework</td></tr><tr><td>JavaScript</td><td>Jest</td></tr><tr><td>JavaScript</td><td>Playwright</td></tr><tr><td>TypeScript</td><td>Jest</td></tr><tr><td>Java</td><td>JUnit</td></tr><tr><td>C#</td><td>NUnit</td></tr><tr><td>API Testing</td><td>Postman Collection (JSON)</td></tr><tr><td>Custom</td><td>User-specified framework</td></tr></tbody></table>

***

## Generating a single script

{% stepper %}
{% step %}

### Open the Script Generator

<div data-with-frame="true"><figure><img src="/files/fA2resfUq9k0uUUK9iQt" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}

### Configure the script

Fill in the generation settings:

<table><thead><tr><th width="157.66668701171875">Field</th><th>Description</th></tr></thead><tbody><tr><td><strong>Project Context</strong></td><td>(Optional) Paste a public GitHub repo URL to tailor scripts to your project's libraries, patterns, and conventions.</td></tr><tr><td><strong>Test Type</strong></td><td>API, UI/E2E, Integration, or Unit</td></tr><tr><td><strong>Language</strong></td><td>Programming language or framework preset</td></tr><tr><td><strong>Generation Profile</strong></td><td>Project conventions, Strict (no external deps), or Custom</td></tr><tr><td><strong>Additional Instructions</strong></td><td>(Optional) Any guidance for code style, naming, assertions, or libraries to use</td></tr><tr><td><strong>Target Path</strong></td><td>(Optional) File path where this script should be placed in your repo (e.g. <code>tests/auth/test_login.py</code>)</td></tr></tbody></table>

<details>

<summary><strong>Test Type differences</strong></summary>

Each test type injects a specific hint into the AI prompt

* **API** - Focuses on HTTP calls, request/response validation, status codes
* **UI/E2E** - Focuses on browser interaction, selectors, visual assertions
* **Integration** - Focuses on service interactions, data flows, side effects
* **Unit** - Focuses on isolated function/method testing, mocking, edge cases

</details>

<details>

<summary><strong>Generation Profile</strong></summary>

* **Project Conventions** - Uses your repository context (if connected) to match existing coding style
* **Strict** - Only uses built-in standard library imports
* **Custom** - Allows you to specify exactly which imports and patterns to use

</details>
{% endstep %}

{% step %}

### Connect repository context (optional but recommended)

For the best script quality, connect your repository so TCG can learn your project's conventions:

1. Click **Connect Repository**.
2. Follow the [GitHub integration](/documentation/apps/tcg-test-case-generator/user-portal/github-integration.md) flow to authorise TCG.
3. TCG scans your repo and detects:
   * Primary language
   * Testing frameworks installed
   * Existing test file patterns
   * Build system (Maven, npm, Gradle, etc.)
   * Allowed imports list
4. This creates an **Executable Profile** that is used to generate scripts that fit your codebase.
   {% endstep %}

{% step %}

#### Pre-flight checks <a href="#pre-flight-checks" id="pre-flight-checks"></a>

Before generating, TCG runs **pre-flight checks** on the test case:

<div data-with-frame="true"><figure><img src="/files/egRe9zxkSH3EXopQmnLt" alt=""><figcaption></figcaption></figure></div>

* **Block** issues prevent generation (unless your profile allows drafts).
* **Warning** issues allow generation but the script may be marked as a draft.

If a blocking issue is found, edit the test case to resolve it, then try again.
{% endstep %}

{% step %}

### Click Generate Script

The script is generated and displayed in a syntax-highlighted code viewer.
{% endstep %}
{% endstepper %}

***

## Understanding the quality score

Every generated script is automatically evaluated with a **Quality Score** (0–100):

| Metric                 | Weight | What it checks                                                        |
| ---------------------- | ------ | --------------------------------------------------------------------- |
| **Assertion Coverage** | 30%    | Number of `assert` / `expect` / `verify` statements relative to steps |
| **Step Coverage**      | 25%    | Ratio of meaningful code lines to total script length                 |
| **No Placeholders**    | 20%    | Absence of `TODO`, `FIXME`, `pass`, `NotImplemented`                  |
| **Allowed Imports**    | 15%    | All imports are from the permitted list                               |
| **No Secrets**         | 10%    | No hardcoded API keys, passwords, or tokens                           |

Scripts scoring:

* **75–100**: Green — ready to use
* **50–74**: Yellow — usable, minor issues
* **< 50**: Red / Draft — significant gaps, manual review required

***

## Actions after generation

| Action                | How                                                                                                                                |
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| **Copy to clipboard** | Click the copy icon in the code viewer                                                                                             |
| **Download script**   | Click **Download** - saves as a `.py`, `.js`, `.ts`, `.java`, `.cs`, or `.json` file                                               |
| **Push to GitHub**    | Click **Push to GitHub** - see [GitHub integration](/documentation/apps/tcg-test-case-generator/user-portal/github-integration.md) |
| **Regenerate**        | Click **Regenerate** to try again with the same or updated settings                                                                |
