> ## Assertions in Antithesis

> Overview of assertions: expressing properties, the message parameter and language-specific implementations.

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

---

This page offers an overview of how assertions work in Antithesis, and high level guidelines on how to add them to your system and [test templates](/docs/product/test_templates/). Languages with first-class assertion support are listed [below](/docs/concepts/properties_assertions/assertions/#assertion-cataloging).

## Assertions express properties

[**Properties**](/docs/concepts/properties_assertions/overview/) describe how your software should behave, in terms a person would use.

You express properties in software by adding **assertions** to the code, using [one of our SDKs](/docs/reference/sdk/).

### Evaluating assertions

Antithesis evaluates each assertion as it's encountered at runtime, to see if the assertion holds in that particular [execution history](/docs/product/debugging/advanced_multiverse_debugging/moment_branch/). Each such evaluation generates an [example or counterexample](/docs/concepts/properties_assertions/properties/#evaluating-properties), which ultimately serves to demonstrate whether the property being asserted [passes or fails](/docs/concepts/properties_assertions/properties/#evaluating-properties). The [triage report](/docs/product/reports/) summarizes your software's behavior as a list of properties which either passed or failed on the relevant test run.

### Common assertion types

Most SDK assertion functions are variants of a few conceptual types:

- **`always(...)` assertions**: Assert that a condition must hold every time this assertion is evaluated. A single `false` evaluation fails the property.
- **`alwaysOrUnreachable(...)` assertions**: Assert that a condition must hold every time it is reached, but also allow "never reached" as passing. This is useful for checks in optional or rare paths.
- **`reachable()` and `unreachable()` assertions**: Assert pure reachability properties. `reachable()` means "this location should be hit at least once"; `unreachable()` means "this location should never be hit."
- **[`sometimes(...)` assertions](/docs/concepts/properties_assertions/sometimes_assertions/)**: Assert that a condition should be true at least once during the run. These are especially useful for checking whether tests exercise meaningful scenarios, not just lines.

The exact function names differ by language, but these semantic categories are consistent across SDKs. For implementation details and language-specific semantics, choose the SDK for your language in [our SDK documentation](/docs/reference/sdk/).

### The `message` parameter

**Assertions** aggregate to **properties** via the `message` parameter.

All Antithesis assertions require a `message` parameter, which appears in the [triage report](/docs/product/reports/) as the name of a property -- so each of the "Control service" properties in the example below is a `message` in an assertion.

Antithesis generates one test property per unique message. If you have multiple assertions with the same `message`, Antithesis labels the property as [passing or failing](/docs/concepts/properties_assertions/properties/#evaluating-properties) by aggregating every assertion with the same `message`.

We therefore *strongly recommend* that `message` should be a human-readable description of the property being expressed.

> **Note**
>
> If you change the `message` in a given assertion between test runs, you'll lose the history of that assertion. Conversely, if you retain the `message` but move the assertion, you'll still be able to track its history across runs (modulo the effects of your moving it).

## Assertions are clues

In addition, assertions provide hints to our platform about which states should be explored in order to search for bugs. This is an important form of guidance for our platform and makes its exploration of your software much more efficient -- in other words, *using assertions ensures you get the best bang for your buck in testing.*

## Performance and failures

All the Antithesis assertions you add to your code (and indeed all our SDKs) are designed to be able to run safely in production with minimal impact on your software’s performance.

Unlike many assertions libraries, failed Antithesis assertions *do not cause your program to exit.* This is useful in test, because we may be able to escalate an assertion failure into a more severe bug. It also reduces the friction to running the exact same code in test and production.

## Under the hood

Under the hood, the assertions added using the SDK each send two JSONL messages to Antithesis:

- One message for assertion declaration in the **assertion catalog** at startup,
- One message for assertion evaluation when encountered during execution.

### Assertion Cataloging

The assertion catalog is the collection of all assertion declarations made at startup.

The assertion catalog initializes every assertion in your software and [test template](/docs/product/test_templates/), and informs Antithesis that they exist. Remember that in [any given execution history](/docs/product/debugging/advanced_multiverse_debugging/moment_branch/), Antithesis may not encounter every assertion you make. Since many types of assertions are supposed to fail if they're never reached, Antithesis must be informed that that these assertions exist so it can mark them as failing when this happens.

Our SDKs handle assertion cataloging for you, though the precise way this happens differs from language to language -- some SDKs include an instrumentor package. Please read the section on [instrumentation](/docs/reference/instrumentation/coverage_instrumentation/) or [our SDK documentation](/docs/reference/sdk/) for details.

## Language-specific references

- [Go Assertions](https://antithesis.com/docs/generated/sdk/golang/assert/)
- [Java Assertions](https://antithesis.com/docs/generated/sdk/java/com/antithesis/sdk/Assert.html)
- [C++ Assertions](/docs/reference/sdk/cpp/assert/)
- [Python Assertions](https://antithesis.com/docs/generated/sdk/python/antithesis/assertions.html)
- [Rust Assertions](https://antithesis.com/docs/generated/sdk/rust/antithesis_sdk/assert/)
- [Languages not listed above](/docs/reference/sdk/fallback/assert/)
