> 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/annotation.md).

# Annotation

Welltested uses annotations to mark the methods in your code to be tested. You can mark classes, extensions or top-level functions.

### `@Welltested()`

You can mark the methods inside a class or an extension to be tested by adding `@Welltested()` annotation to the parent class/extension.&#x20;

```dart
import 'package:welltested_annotation/welltested_annotation.dart';

@Welltested()
class Auth {
    Future<void> logInUser() {...}
    Future<void> logOutUser() {...}
}
```

In the above example, we will generate unit tests for `logInUser` and `logOutUser` methods of `Auth` class.

**Annotating Top Level Functions:**

If you've top-level functions in your code that do not belong to a class or extension method, you can annotate them directly.&#x20;

```dart
import 'package:welltested_annotation/welltested_annotation.dart';

@Welltested()
double cartCalculator(List<CartItem> items, double tax) {...} // top-level function

```

### Testcases

Our testing AI examines and self creates smart exhaustive test cases for each function based on its use case and contextual code. However, you can specify your own custom test cases for a method by adding [`@Testcases()`](/documentation/unit-tests/good-to-knows/custom-testcases.md) annotation to them.

```dart
class Auth {
  @Testcases([
    "Ensure token is saved if login is successful",
    "Ensure existing token is cleared if login fails"
  ])
  Future<void> logInUser() {...}
  Future<void> logOutUser() {...}
}
```

### Exclude Methods

By default, all methods in an annotated class are included. To exclude any method from testing, add their name to the `excludedMethods` list in the `Welltested` annotation.

```dart
@Welltested(excludedMethods: ['logOutUser'])
class Auth {
    Future<void> logInUser() {...}
    Future<void> logOutUser() {...}
}
```

In the above case, we will not create unit tests for `logOutUser`.


---

# 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/annotation.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.
