rvtest 0.2.0

A Next Level Testing Library for Rust — BDD specs, property-based testing, parametrized tests, rich reporting, and code coverage
Documentation
//! **rvtest** — A Next Level Testing Library for Rust.
//!
//! `rvtest` extends Rust's built-in testing capabilities with:
//!
//! - **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 macros** — `assert_eq!` with structural diffs, `assert_ok!`,
//!   `assert_err!`, `assert_matches!`, `assert_delta!`.
//! - **Mocking utilities** — `Spy` (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, and GitHub Actions annotations formats.
//! - **Code coverage** — measure line/function/region coverage via
//!   pure-Rust `.profraw` parser (`cargo rvtest --coverage`). No external
//!   LLVM tools required.
//! - **Configurable runner** — parallel execution, name and tag filtering,
//!   fail-fast, configurable timeouts and retries.
//! - **Optional proc-macro API** — `#[describe]` / `#[it]` attribute macros
//!   via the `macros` feature.
//!
//! # Usage inside `#[test]` (recommended)
//!
//! Rvtest is designed to be used inside standard `#[test]` functions.
//! Build a spec with [`describe`](spec::describe) and [`it`](spec::Spec::it), call
//! [`run`](spec::Spec::run), then verify with [`assert_all_pass`](core::TestSuite::assert_all_pass):
//!
//! ```ignore
//! 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")
//!         .run()
//!         .assert_all_pass();
//! }
//! ```
//!
//! Tags let you selectively run tests: `cargo rvtest --tag arithmetic`.
//! Other modifiers include `.timeout(dur)` and `.retries(n)`.
//!
//! # Property-based testing inside `#[test]`
//!
//! ```ignore
//! use rvtest::property::{check, any};
//!
//! #[test]
//! fn addition_is_commutative() {
//!     check("commutativity", any::<i32>(), |a: &i32| {
//!         let b: i32 = 42;
//!         a + b == b + *a
//!     });
//! }
//! ```
//!
//! # Parametrized tests inside `#[test]`
//!
//! ```ignore
//! use rvtest::param::parametrize;
//!
//! #[test]
//! fn addition_cases() {
//!     for case in parametrize("add", [(1, 1, 2), (0, 0, 0), (-1, 1, 0)], |(a, b, exp)| {
//!         assert_eq!(a + b, *exp);
//!     }) {
//!         assert!(case.status.is_passed(), "{} failed", case.name);
//!     }
//! }
//! ```
//!
//! # CLI usage (`cargo rvtest`)
//!
//! The `cargo-rvtest` binary runs specs defined in your project and
//! produces formatted output. See `cargo rvtest --help`.

pub mod arch;
pub mod assert;
pub mod capture;
pub mod core;
pub mod daemon;
pub mod mock;
pub mod coverage;
pub mod coverage_raw;
pub mod param;
pub mod property;
pub mod report;
pub mod runner;
pub mod snapshot;
pub mod spec;
pub mod tag;

/// Re-export of the optional proc-macro crate.
///
/// Enabled via the `macros` feature:
///
/// ```toml
/// [dependencies]
/// rvtest = { version = "0.2", features = ["macros"] }
/// ```
///
/// Then use:
///
/// ```ignore
/// use rvtest::*;
/// ```
#[cfg(feature = "macros")]
pub use rvtest_macros::{after_all, before_all, describe, it, retries, tag, timeout};

/// The `prelude` module re-exports the most commonly used types and
/// functions for convenience.
pub mod prelude {
    pub use crate::arch::{arch_check, ArchCheck};
    pub use crate::core::{CoverageFormat, CoverageReport, ReportFormat, RunnerConfig, TestRun, TestStatus, TestSuite};
    pub use crate::coverage::{CoverageCollector, CoverageConfig};
    pub use crate::param::{parametrize, parametrize_named};
    pub use crate::property::{any, check, check_with, PropertyConfig, Strategy};
    pub use crate::runner::TestRunner;
    pub use crate::snapshot::{assert_snapshot, assert_snapshot_in};
    #[cfg(feature = "macros")]
    pub use rvtest_macros::{after_all, before_all, describe, it, retries, tag, timeout};
    #[cfg(not(feature = "macros"))]
    pub use crate::spec::{describe, Spec};
}