Releases

RXpect brings macro-free fluent assertions to Rust tests

RXpect strips macros out of Rust assertions and leans on traits, aiming for tests that read fluently and still play nicely with RustRover autocomplete.

Nina Kowalski··2 min read
Published
Listen to this article0:00 min
RXpect brings macro-free fluent assertions to Rust tests
Source: The Rust Programming Language Forum

RXpect arrived as a small but pointed challenge to the usual Rust testing style: can fluent assertions feel natural without burying users in macros? The crate went public on June 16, 2026, after its maintainer said it had already been used personally for about two and a half years, and the first thing it advertises is restraint. At launch, RXpect had zero macros in its public design.

That choice is not just aesthetic. The maintainer argued that many assertion crates lean so hard on macros that they can get in the way of RustRover autocomplete, and JetBrains’ own RustRover documentation makes code completion a core feature. RXpect takes the opposite route, building around traits and structs instead. Its API centers on Expectation, ExpectationBuilder, and ExpectProjection, with custom expectations added through extension traits rather than a bespoke macro language.

AI-generated illustration
AI-generated illustration

In use, RXpect is trying to make tests read like a chain of intent. It handles Result and Option directly, supports projecting fields before assertions, and lets several expectations pile onto one value so a single test run can report multiple failures at once. That matters when you are checking a richer struct or response object, because plain assert_eq! often gives you one mismatch and sends you back through the same test again. RXpect’s approach is closer to a test that keeps talking long enough to show you everything that is wrong.

The crate also enters a crowded assertion ecosystem with a very specific pitch. The asserting crate leans on a prominent assert_that! macro, soft assertions, and colored diffs. spectral also recommends assert_that! for accurate file-and-line reporting and offers named subjects and mapping helpers. assertr emphasizes method chaining and custom assertions, but still uses derive macros for partial struct assertions. RXpect’s distinction is that it tries to keep macros out of the public-facing experience as much as possible.

That restraint extends to packaging as well. With default features disabled, RXpect has zero non-dev dependencies. Turn on iterable assertions and it adds itertools; enable diffing and it brings in colored and related crates, both of which are enabled by default. The maintainer’s roadmap points to global and local configuration, custom reason phrases, OR-semantics, and enum assertions, while the code and issue tracker live on Codeberg. GitHub shows no tagged releases yet, which leaves RXpect early enough for more changes but mature enough to feel like a deliberate answer to a familiar Rust pain point: when assertions become too macro-heavy, even good ergonomics can start fighting the language.

This article was produced by Prism’s automated news system from verified source data, official records, and press releases, then run through automated quality and moderation checks before publishing. The system is built and supervised by the people who set the standards it runs under. Read our full AI policy.

Did this article answer your question?

Discussion

More Rust Programming News