> For the complete documentation index, see [llms.txt](https://docs.welltested.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.welltested.ai/documentation/unit-tests/generate-tests.md).

# Generate Tests

To generate tests for your annotated classes, run the command:

```
welltested generate unit
```

The execution can take anywhere between 1-10 minutes to generate tests depending upon the number of methods.&#x20;

After a successful run, the tests appear in `/test` directory of your project.

> In the beginning, we recommend you generate tests in batches for the best results. Check [The Batching Rule](/documentation/unit-tests/good-to-knows/the-batching-rule.md)

### Scope Arguments \[Optional]

You may use the scope arguments to generate tests only for a certain file, class and/or method.

Examples:

`welltested generate unit -f lib/login/repository.dart`

`welltested generate unit -c AccountsRepository -m getAllTransactions`

*-f, -c or -m* can all be used independently of each other and will narrow the scope accordingly.

### Maintaining Tests

If you make any changes to your existing functions or add new methods, you can run the same commands and welltested will auto-update the tests.&#x20;

We ensure that your tests always stay up to date with minimal maintenance efforts 🙌🏼


---

# 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://docs.welltested.ai/documentation/unit-tests/generate-tests.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.
