datatest-stable

A Rust test harness for file-driven, data-driven tests that runs on stable Rust.

Library
Cargo
v0.3.3
52stars
MIT OR Apache-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
74/100Good
Development Activity100
Maintenance84
Community44
Maturity56
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
82/100Excellent
Architecture82
Code Quality84
Innovation78
Learning Curve82

datatest-stable is a test harness for writing file-driven (data-driven) tests in Rust, where test case fixtures are supplied as files on disk rather than hand-written in code. You point it at a directory and a filename pattern, and it invokes your test function once for every matching file, recursing through subdirectories automatically.

Unlike the original datatest crate, datatest-stable works on stable Rust with no nightly features required. It is part of the nextest-rs organization and integrates cleanly with cargo nextest, where each fixture becomes its own separately reported, independently runnable test.

What You Get

  • A harness! macro that maps directories of fixtures to individual test cases
  • Recursive directory traversal with regex-based file matching
  • Test functions that receive a path and optionally the file contents as a string or bytes
  • First-class cargo nextest integration where each fixture runs as its own process
  • Stable-Rust operation with no nightly toolchain or unstable features required

Common Use Cases

  • Snapshot and golden-file testing where inputs and expected outputs live as files
  • Testing parsers, compilers, or formatters against a corpus of example inputs
  • Validating serialization or transformation logic across many fixture files
  • Growing a test suite by dropping in new fixture files without editing code

Under The Hood

Architecture — datatest-stable is built around a compile-time macro and a runtime file walker. The harness! macro (src/macros.rs) expands the user’s test declarations into a main function that replaces the default libtest harness. At runtime the data-source layer (src/data_source.rs) uses walkdir to recursively enumerate the configured root directory and fancy-regex to filter files against the supplied pattern, optionally loading each file’s contents as a string or byte vector. The runner (src/runner.rs) wraps libtest-mimic to register one test per matching file and to produce libtest-compatible output, which is what lets cargo nextest treat every fixture as an independent test.

Tech Stack — Written in Rust (2021 edition, MSRV 1.72). Core dependencies are libtest-mimic for the custom harness, walkdir for traversal, fancy-regex for pattern matching, and camino for UTF-8 path handling; an optional include_dir feature embeds fixtures into the binary. Development uses trybuild for macro compile-fail tests.

Code Quality — The crate is small and focused, split into clear data-source, runner, and macro modules. It carries a maintained CHANGELOG, compile-fail tests via trybuild, and integration/example test targets. Rust-version and lint configuration are pinned in Cargo.toml, and the project is actively maintained under the nextest-rs organization.

API Design — The public surface is a single declarative harness! macro plus a re-exported Result type and Utf8Path. Test functions come in several accepted signatures so authors can take just a path or also receive file contents, keeping boilerplate minimal. Documentation is thorough via rustdoc and docs.rs, and the harness = false setup mirrors idiomatic custom-harness conventions Rust developers already know.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search