Skip to main content

Crate rsspec

Crate rsspec 

Source
Expand description

§rsspec — A Ginkgo/RSpec-inspired BDD testing framework for Rust

Write expressive, structured tests using a closure-based API with describe, context, it, lifecycle hooks, table-driven tests, and more.

§Quick example

rsspec::run(|ctx| {
    ctx.describe("Calculator", |ctx| {
        ctx.it("adds two numbers", || {
            assert_eq!(2 + 3, 5);
        });

        ctx.context("with negative numbers", |ctx| {
            ctx.it("handles negatives", || {
                assert_eq!(-1 + 1, 0);
            });
        });
    });
});

§Features

  • googletest — re-exports googletest matchers via rsspec::matchers
  • tokio — async test support via async_it, async_before_each, etc.

Macros§

by
Document a step within a test (macro form).
skip
Skip the current test at runtime. Prints the reason and returns from the test.

Structs§

Context
A lightweight handle for defining BDD test structure.
Guard
A drop guard that runs cleanup code even if the test panics.
ItBuilder
Builder returned by Context::it. Supports chaining decorators and registers the test node when dropped.

Functions§

by
Document a step within a test. Prints the step description to stderr.
defer_cleanup
Register a cleanup function that will run after the current test completes.
run
Build and run a BDD test suite.
run_inline
Build and run a BDD test suite inline, compatible with #[test] functions.
skip
Skip the current test at runtime with a reason.