Skip to main content

test_better_core/
lib.rs

1//! `test-better-core`: error and result types.
2//!
3//! This crate is the foundation of the `test-better` testing library. It makes
4//! `?` viable as the single control-flow operator of a test by providing:
5//!
6//! - [`TestError`], the structured failure type, and its parts ([`ErrorKind`],
7//!   [`ContextFrame`], [`Payload`]);
8//! - [`TestResult`], the `?`-friendly return type for tests and helpers;
9//! - [`ContextExt`], which attaches "while doing X" context to a fallible value;
10//! - [`OrFail`], the `?`-friendly alternative to panicking on the error path;
11//! - [`Trace`], which records in-test breadcrumbs attached to any failure;
12//! - [`StructuredError`], the owned/serializable mirror that tooling consumes;
13//! - [`RUNNER_ENV`]/[`STRUCTURED_MARKER`], the structured-output channel the
14//!   optional `cargo test-better` runner consumes.
15//!
16
17mod color;
18mod context;
19mod error;
20mod or_fail;
21mod render;
22mod result;
23mod runner;
24mod structured;
25mod trace;
26
27pub use color::{ColorChoice, color_choice, set_color_choice};
28pub use context::ContextExt;
29pub use error::{ContextFrame, ErrorKind, Payload, TestError};
30pub use or_fail::OrFail;
31pub use result::TestResult;
32pub use runner::{RUNNER_ENV, STRUCTURED_MARKER};
33pub use structured::{SourceLocation, StructuredContextFrame, StructuredError, StructuredPayload};
34pub use trace::{Trace, TraceEntry};