rvtest 0.3.1

A Next Level Testing Library for Rust — BDD specs, property-based testing, parametrized tests, rich reporting, and code coverage. Just a library, not a framework.
Documentation
rvtest-0.3.1 has been yanked.

rvtest — A Next Level Testing Library for Rust.

Just a library — not a framework, not a product.

rvtest extends Rust's built-in testing capabilities with a rich suite of features:

It does not replace #[test] or cargo test. It does not require you to adopt a new framework or restructure your project. You add it as a dev-dependency and use it exactly where it helps — nothing more.

  • BDD-style specs — organise tests with describe / it blocks, nested hierarchies, lifecycle hooks (before_all, after_all, before_each, after_each), tags, timeouts, and retries.
  • Property-based testing — verify invariants over randomly generated inputs, with automatic counterexample shrinking.
  • Parametrized tests — run the same test logic against multiple inputs without boilerplate.
  • Assertion macrosassert_eq! with structural diffs, assert_ok!, assert_err!, assert_matches!, assert_delta!.
  • Mocking utilitiesSpy (call-recording), Stub (fixed return), patch! (scoped function replacement). No proc-macro required.
  • Snapshot testing — file-based snapshot assertions with --update-all auto-accept and --review interactive mode.
  • Architecture tests — enforce module dependency rules (may_depend_on, may_not_depend_on, must_not_have_cycles, public_api_doc_required).
  • Output capture — per-test stdout/stderr capture, shown only on failure.
  • Rich reporting — Pretty (human-readable with colour), TAP, JUnit XML, JSON, Compact, GitHub Actions annotations, and Agent-native (LLM-optimised JSON with source snippets).
  • Code coverage — measure line/function/region coverage via pure-Rust .profraw parser (cargo rvtest --coverage). No external LLVM tools required. Falls back to cargo-llvm-cov or llvm-tools when available.
  • Configurable runner — parallel execution, name/tag/skip filtering, fail-fast, configurable timeouts, retries, and execution-order shuffling.
  • Flaky quarantine--quarantine skips known-flaky tests; --flaky-report lists them.
  • Git-aware test selection--changed auto-filters tests based on git diff.
  • Last-run cache--retest / --failed re-runs only previously failed tests; --diff shows new failures, recovered tests, and duration changes.
  • Environment & filesystem utilitiesrvtest::env (RAII env var guards) and rvtest::fs (auto-cleaning temp directories).
  • Optional proc-macro API#[describe] / #[it] attribute macros via the macros feature.
  • Zero proc-macro deps by default — Everything works with plain Rust functions and closures inside standard #[test] functions.

Library API

Use rvtest inside standard #[test] functions:

use rvtest::spec::describe;

#[test]
fn calculator_tests() {
    describe("Calculator")
        .it("adds two positive numbers", || {
            assert_eq!(2 + 2, 4);
        })
        .it("subtracts", || {
            assert_eq!(5 - 3, 2);
        })
        .tag("arithmetic")
        .timeout(std::time::Duration::from_secs(2))
        .retries(1)
        .run()
        .assert_all_pass();
}

CLI (cargo rvtest)

The cargo-rvtest binary (install via cargo install cargo-rvtest) runs your project's tests via cargo test and renders results in any supported format. See cargo rvtest --help for all options.

Feature flags

  • macros — Enables #[describe] / #[it] proc-macro attributes (re-exported from rvtest-macros).