xpct
xpct is an extensible test assertion library for Rust. It's designed to be ergonomic, batteries-included, and test framework agnostic.
Want to get started? Check out the tutorial.
About
xpct is extensible. In addition to allowing you to write custom matchers, it separates the logic of matchers from how they format their output, meaning you can:
- Hook into existing formatters to write custom matchers with pretty output without having to worry about formatting.
- Customize the formatting of existing matchers without having to reimplement their logic.
This crate aims to provide many useful matchers out of the box. Check out the full list of provided matchers.
Docs
Examples
A simple equality assertion, like assert_eq:
use ;
expect!.to;
Unwrapping a Some value to make an assertion on the wrapped value:
use ;
expect!
.to
.to;
Making assertions about individual fields of a struct:
use ;
let player = Player ;
expect!.to;
Making assertions about elements in a collection:
use ;
let items = vec!;
expect!
.to
.to;
Showing rich diffs of data structures:
use ;
expect!.to;
MSRV Policy
The last two stable Rust releases are supported. Older releases may be supported as well.
The MSRV will only be increased when necessary—not every time there is a new Rust release. An increase in the MSRV will be accompanied by a minor semver bump if >=1.0.0 or a patch semver bump if <1.0.0.
Semver Policy
Prior to version 1.0.0, breaking changes will be accompanied by a minor version bump, and new features and bug fixes will be accompanied by a patch version bump.