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

# How to Generate Test Cases with Kane CLI

> Turn a plain-language description of what to test into structured scenarios and test cases with kane-cli generate, then save them as runnable _test.md files.

`kane-cli generate` turns a plain-language description of *what you want to test* into structured **test scenarios** and **test cases**. You do not write them by hand, and no browser is launched. This page covers AI test-case generation from the command line and from the interactive Kane CLI TUI.

A generation produces:

* **Test Scenarios**: groups of related checks, such as "Login" or "Checkout".
* **Test Cases**: the individual checks inside each scenario, each typed **Positive**, **Negative**, or **Edge**.

You generate a set, review it, and **refine** it in plain language as often as you like. You can then **save** the functional cases as runnable `_test.md` files, which [`kane-cli testmd`](https://www.testmuai.com/docs/kane-cli-testmd-running) can run and replay.

> [!NOTE]
>
> The CLI **takes a text description**, optionally with local files attached through [`--files`](#attaching-files-for-context), and writes local `_test.md` files. For the full picture of AI test-case generation, including issue-link inputs, dashboards, and pushing cases into Test Manager or automation, see the [AI test-case generation guide](https://www.testmuai.com/support/docs/generate-test-cases-with-ai/). See also [Limits and scope](#limits-and-scope).

## Quick start

```bash theme={null}
# 1. Generate from a description
kane-cli generate "checkout flow on a shopping site"

# 2. Refine it (repeat as needed)
kane-cli generate "also cover an expired card and an out-of-stock item" --refine --req 23271

# 3. Save the functional cases as runnable tests
kane-cli generate --save --req 23271
#    → .testmuai/tests/<suite>/<scenario>/<case>_test.md

# 4. Run them
kane-cli testmd run .testmuai/tests/checkout-23271/login/valid-credentials_test.md
```

Each generation ends by printing a request id (`23271` above). Pass it to later commands to continue the same request.

## The three modes

From a script or a headless shell, `generate` runs **one turn per command, then exits**. To continue a request, run the command again with `--req <id>`. When you run it interactively, Kane CLI opens a live TUI session instead. See [Interactive mode (TUI)](#interactive-mode-tui).

| Mode | Command | What it does |
| - | - | - |
| **New** | `kane-cli generate "<what to test>"` | Starts a new request and generates scenarios and cases. Prints a request id. |
| **Refine** | `kane-cli generate "<change>" --refine --req <id>` | Adjusts an existing request in plain language: add coverage, narrow scope, change focus. |
| **Save** | `kane-cli generate --save --req <id> [--out <dir>]` | Writes the request's **functional** cases to `_test.md` files. No new generation. |

`--refine` and `--save` both require `--req`. `--refine` needs a description of the change. `--save` takes no description.

## Options

| Option | Purpose |
| - | - |
| `--req <id>` | The request id to refine or save. |
| `--out <dir>` | Where `--save` writes. Defaults to `<cwd>/.testmuai/tests` (the same location the TUI uses). |
| `--name <name>` | Names the run and the saved suite folder. |
| `--scenario-limit <n>` | Maximum number of scenarios to generate. |
| `--per-scenario-limit <n>` | Maximum test cases per scenario. |
| `--memory` | Use the **memory layer**: reuse relevant existing test cases and reduce duplicates. |
| `--files <paths>` | Comma-separated local files to attach as context (new generations and refines only). See [Attaching files for context](#attaching-files-for-context). |
| `--project <id>` / `--folder <id>` | Test Manager project and folder. |
| `--agent` | Emit structured NDJSON on stdout. Turns on automatically when the command runs non-interactively or is piped. |
| `--username`, `--access-key` | Authentication, same as [`kane-cli run`](https://www.testmuai.com/docs/kane-cli-quickstart). See [Authentication](https://www.testmuai.com/docs/kane-cli-authentication.md). |

## Attaching files for context

Give the generator more context by attaching local files with `--files`, a comma-separated list of paths. You can attach files to a **new** generation or a **refine**:

```bash theme={null}
kane-cli generate "test the login flow described in the attached spec" --files ./login-spec.pdf,./wireframe.png
```

The files are sent with your description, and the generated scenarios and cases take them into account. For example, attach a spec, a screenshot of the UI, a PDF or Word document, or a CSV of inputs.

* **Supported types**: documents (`.txt`, `.md`, `.json`, `.xml`, `.csv`, `.pdf`, `.docx`, `.xlsx`), images (`.jpg`, `.jpeg`, `.png`, `.gif`, `.bmp`, `.webp`), audio (`.mp3`, `.wav`, `.m4a`), and video (`.mp4`, `.mov`, `.webm`, `.mpeg`, `.mpga`).
* **Limits**: up to **10 files**, each **50 MB** or smaller.
* **Checked before anything is sent**: Kane CLI validates all paths together. If any file is missing, has an unsupported type, is too large, or exceeds the count, the command stops and lists the problem paths, so nothing is uploaded by mistake. Files outside the current directory are allowed, with a warning.
* **Not with `--save`**: files attach to a generation or a refine, not to a save. Kane CLI rejects `--files` combined with `--save`.

In the interactive TUI, type `@` in the generate prompt to attach a file inline instead of passing `--files`.

## Interactive mode (TUI)

The commands above are for scripts. The Kane CLI TUI **opens in Run mode**, for running tests, by default. Switch to **Generate mode** with **`/generate`**, and back with `/run`. To go straight there, run `kane-cli generate "<objective>"` in a terminal without `--agent`. The TUI opens in Generate mode and submits your objective.

Unlike the one-turn command line, the TUI is a **live session**. Generated scenarios stay pinned in a **Scenarios** box, where you refine and browse them in place:

| Input | Action |
| - | - |
| *(type any text)* | **Refine**: describe a change in plain language; the set updates in place |
| `@<file>` | **Attach a file**: type `@` to pick a local file to add as context (same files as `--files`) |
| `/view [S<n>]` | Open the **scenario browser**: drill scenarios → cases → case detail |
| `/save` | Save the functional cases to `<cwd>/.testmuai/tests/…` |
| `/cancel` | Cancel the current generation |
| `/run` | Switch back to Run mode |

In the scenario browser, use `↑↓` to move, `↵` to open, `◂ ▸` for the previous or next sibling, `x` to remove a case, and `←` or `esc` to go back. **Non-functional cases** (Security, Performance, and so on) show a **gray `✓`** with a "won't be saved" note, because `/save` writes only functional cases. See [Saving is functional-only](#saving-is-functional-only).

If generation asks a **clarifying question**, type your answer to continue. After `/save`, the files are ordinary `_test.md` tests under `.testmuai/tests/`. Run them with [`kane-cli testmd run`](https://www.testmuai.com/docs/kane-cli-testmd-running).

## How a result is shaped

Each generated case carries:

* a **title** and **steps**,
* a **type**: Positive (expected to pass), Negative (tests failure handling), or Edge (corner cases),
* a **category**, such as *Functional*, *Security*, or *Performance*,
* a **priority**.

Scenarios are sorted by importance. The full result is returned at the end of the turn, so you can review it before you refine or save.

## Saving is functional-only

`--save` writes **only test cases whose category is *Functional***, because only those translate into runnable `_test.md` tests. Non-functional cases (Security, Performance, and so on) are generated and shown, but they are **not** written to disk. If a request has no functional cases, `--save` writes nothing and tells you so.

Saved files are ordinary `_test.md` tests in the standard format, the same as a hand-written test. Everything in [the testmd docs](https://www.testmuai.com/docs/kane-cli-testmd.md) applies to them: you can run them, edit them, replay them from cache, and commit them to git.

The intended workflow is: **generate writes the test cases, then testmd runs them.**

## Limits and scope

* **Input is a text description, optionally with attached files.** Attach local files with `--files`, such as a spec, screenshot, PDF, or CSV, to give the generator more context. The CLI does not support issue-link inputs or the web product's "Create / Create and Automate".
* **Refinement applies to the whole request.** You refine the request as a whole in plain language. The CLI does not support targeting an individual scenario or case.
* **Scenario and per-scenario counts** are capped by `--scenario-limit` and `--per-scenario-limit`.

## Next steps

* [The generate workflow](https://www.testmuai.com/docs/kane-cli-generate-workflow.md): the new → refine → save → run loop, worked examples, and exit codes.
* [Running tests with testmd](https://www.testmuai.com/docs/kane-cli-testmd-running.md): run and replay the `_test.md` files `--save` produces.
* [Authentication](https://www.testmuai.com/docs/kane-cli-authentication.md): logging in and choosing an environment.

## Terminal First Testing With Kane CLI

Natural language browser & mobile app tests right from terminal.

Book a Demo

![Kane CLI terminal](https://assets.testmu.ai/resources/images/Terminal-KaneCLI.png)

×

Schedule Your Personal Demo

<form>
  Select Product

  Schedule Demo
</form>


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