Expand description
test-better-core: error and result types.
This crate is the foundation of the test-better testing library. It makes
? viable as the single control-flow operator of a test by providing:
TestError, the structured failure type, and its parts (ErrorKind,ContextFrame,Payload);TestResult, the?-friendly return type for tests and helpers;ContextExt, which attaches “while doing X” context to a fallible value;OrFail, the?-friendly alternative to panicking on the error path;Trace, which records in-test breadcrumbs attached to any failure;StructuredError, the owned/serializable mirror that tooling consumes;RUNNER_ENV/STRUCTURED_MARKER, the structured-output channel the optionalcargo test-betterrunner consumes.
Structs§
- Context
Frame - One human-readable frame in a
TestError’s context chain. - Source
Location - A source location, owned and serializable (the plain-data form of
std::panic::Location). - Structured
Context Frame - The plain-data form of
crate::ContextFrame. - Structured
Error - The plain-data, owned, serializable mirror of
TestError. - Test
Error - A test failure.
- Trace
- A scoped collector of in-test breadcrumbs.
Enums§
- Color
Choice - When rendered failures should use ANSI color.
- Error
Kind - The category of a
TestError. - Payload
- Structured detail attached to a
TestErrorbeyond its message. - Structured
Payload - The plain-data form of
Payload. - Trace
Entry - One breadcrumb recorded on a
Trace.
Constants§
- RUNNER_
ENV - The environment variable the runner sets on the
cargo testit spawns. - STRUCTURED_
MARKER - The sentinel that brackets the JSON structured-error payload on its own line in captured test output. Chosen to be unmistakable in prose and to sit alone on a line.
Traits§
- Context
Ext - Attaches context to the failure path of a
Resultor theNoneof anOption. - OrFail
- Converts a fallible value into a
TestResult, producing aTestErroron the failure path.
Functions§
- color_
choice - Returns the process-wide
ColorChoice. - set_
color_ choice - Sets the process-wide
ColorChoicefor rendered failures.
Type Aliases§
- Test
Result - The result type returned by
test-bettertests and helpers.