> ## Documentation Index
> Fetch the complete documentation index at: https://site.aspect.build/llms.txt
> Use this file to discover all available pages before exploring further.

# Flags and Tags

> Learn how Bazel test flags and tags work, including size, timeout, and filters like --test_size_filters that control how tests run and which targets execute.

All Bazel test rules share [common attributes](https://bazel.build/reference/be/common-definitions#common-attributes-tests) that control how tests are executed and how they can be filtered. These attributes are useful for organizing tests by purpose, execution time, and scope.

## Common test attributes

### Size

The `size` attribute is an architectural hint. It affects both the default timeout and the amount of system resources Bazel allocates when scheduling the test.

Common size values include:

| Size     | Typical use      | Characteristics  |
| -------- | ---------------- | ---------------- |
| small    | unit test        | short timeout    |
| medium   | functional test  | moderate timeout |
| large    | integration test | long timeout     |
| enormous | end-to-end test  | eternal timeout  |

### Timeout

You could specify an explicit `timeout` value, either in addition to or instead of `size`.

<Warning>
  Unfortunately, `timeout` has an undesirable default value of `moderate`. It
  should be the shortest value so that developers are reminded to increase it
  when a test times out.
</Warning>

## Filtering tests

The `size` attribute is useful for filtering. For example, you can use `--test_size_filters=small` to ask Bazel to run a unit test.

You can also filter with these flags:

### Filter by tags

This command runs only tests tagged with `smoke`.

```bash theme={null}
bazel test //... --test_tag_filters=smoke
```

### Filter by timeout

This command will skip running tests that take a long time.

```bash theme={null}
bazel test //... --test_timeout_filters=-eternal
```

<Note>
  By default, the eternal timeout corresponds to approximately 15 minutes. For
  details on timeout values and behavior, see the [Bazel Test
  Encyclopedia](https://bazel.build/reference/test-encyclopedia#role-test-runner).
</Note>

### Filter by language

This command runs only js\_test and go\_test targets.

```
bazel test //... --test_lang_filters=js,go
```

## Well-known tags

You can add these to the `tags` attribute of a test to change the way Bazel runs it.

* `external` - the test is intentionally non-hermetic, as it tests something aside from its declared inputs. Forces the test to be unconditionally executed,
  regardless of the value of `--cache_test_results`, so the result is not cached.
* `exclusive` - the test is not isolated and can interact with other tests running at the same time. Exclusive tests are executed in serial fashion after all build activity and non-exclusive tests have been completed. They can't be run remotely, either.
* `manual` - essentially "skip" or "disabled". It means a target wildcard pattern, like `:all` or `//...` won't include this target. You can still run it by listing the target explicitly.
* `requires-network` - declare that the test should run in a sandbox that allows network access.
* `flaky` - run it up to three times when it fails. We’ll learn more about flakiness in a later lesson.

<Note>
  The Aspect CLI provides a handy way to find these: `bazel help tags`
</Note>
