# 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()`](https://docs.welltested.ai/documentation/unit-tests/good-to-knows/custom-testcases) 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`.
