# tesults-test
A Rust integration for [Tesults](https://www.tesults.com) that replaces `#[test]` with `#[tesults_test::test]` to add enhanced test reporting — timing, descriptions, steps, custom fields, and file attachments — with no changes to how you run tests.
## Installation
Add to `[dev-dependencies]` in `Cargo.toml`:
```toml
[dev-dependencies]
tesults-test = "1"
```
## Usage
Replace `#[test]` with `#[tesults_test::test]`:
```rust
#[cfg(test)]
mod tests {
#[tesults_test::test]
fn it_adds() {
assert_eq!(2 + 2, 4);
}
}
```
Set `TESULTS_TARGET` and run tests as usual:
```bash
TESULTS_TARGET=token cargo test
```
Results are uploaded to Tesults once after all tests complete. If `TESULTS_TARGET` is not set, nothing is uploaded.
## Enhanced reporting
Call these helpers inside a test body to enrich the result:
```rust
#[tesults_test::test]
fn checkout_flow() {
tesults_test::description("Verifies the full checkout flow end to end");
tesults_test::custom("env", "staging");
tesults_test::custom("build", "1.4.2");
tesults_test::step("open cart", "pass", "Cart page loads", "");
tesults_test::step("enter address", "pass", "Address form submits", "");
tesults_test::file("/tmp/screenshot.png");
assert!(place_order());
}
```
| `tesults_test::description(text)` | Free-text description shown in Tesults |
| `tesults_test::custom(key, value)` | Custom key-value field |
| `tesults_test::step(name, result, desc, reason)` | Named step with pass/fail |
| `tesults_test::file(path)` | File path to upload (screenshot, log, etc.) |
## `#[should_panic]`
Works as normal — `#[should_panic]` stays on the function and `#[tesults_test::test]` records the correct pass/fail:
```rust
#[tesults_test::test]
#[should_panic(expected = "overflow")]
fn panics_on_overflow() {
let _: u8 = 200u8 + 200u8;
}
```
## Config file (optional)
Keep tokens out of scripts with a key name and a config file:
```bash
TESULTS_TARGET=my-target TESULTS_CONFIG=/path/to/tesults.cfg cargo test
```
`tesults.cfg` format:
```
# Tesults target tokens
my-target = eyJ0eXAiOiJ...
staging = eyJ0eXAiOiK...
```
## Suite names
The suite for each test is derived from its Rust module path. A test in `my_crate::tests` is reported under suite `tests`. Tests in integration test files (`tests/my_test.rs`) use the file stem as the suite name.
## Documentation
[https://www.tesults.com/docs/rust-test](https://www.tesults.com/docs/rust-test)