# Testing

Stof has a thin testing layer built in, just like "run". Test functions are given the attribute #\[test], and are always run as a separate asynchronous process.

```rust
#[test]
fn passes() {
    assert(true);
    assert_eq("hi", "hi");
    assert_not(false);
    assert_neq("hi", 42);
}
```

{% hint style="info" %}
Assert functions are a part of the [Standard Library (Std)](/libraries/standard-library-std.md).
{% endhint %}

If you expect the test to throw an error, add a #\[errors] attribute as well.

```rust
#[test]
#[errors]
fn passes() {
    throw("this is an expected error");
}
```

## Running Tests

With the CLI, use `stof test` instead of `stof run`. You'll see some nice-looking output for each test that ran, and then any failures that occurred at the bottom of the output. Errors will include a small stack trace so you can get a good idea of where things went wrong.

{% hint style="info" %}
Errors and debug information are a big area of improvement - please consider helping out if you love Stof.
{% endhint %}


---

# Agent Instructions: 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:

```
GET https://docs.stof.dev/common-patterns/testing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
