Testing And Benchmarking

Test, feature-matrix, fuzzing, property, and benchmark tools should be chosen by risk and feedback cost. This mechanism helps match validation depth to the behavior, integration surface, or performance claim under review.

Purpose

Choose validation tools by the kind of risk being controlled. Fast local checks protect the edit loop. Broader CI matrices protect integration surfaces. Heavy checks such as fuzzing, property tests, feature matrices, or benchmarks should be targeted at risks where the added runtime buys real information.

Supported Principles

Normal Checks

  • Run cargo test or cargo nextest run for normal correctness gates.
  • Run format and lint checks early when they are cheap and deterministic.
  • Keep slow or flaky checks out of the default PR loop unless they control a high-value risk.

Feature and Boundary Checks

  • Use cargo hack for no-default, each-feature, all-features, and selected feature combinations.
  • Use pinned toolchain or MSRV checks when Rust version support is a public contract.
  • Use realistic parser samples for formats, protocols, and integrations.
  • Use fuzzing or property tests for parsers, decoders, state machines, and untrusted input.

Performance Checks

  • Use criterion, repeated hyperfine, or saved benchmark scripts for performance claims.
  • Record benchmark provenance: command, dataset, environment, compared revisions, and goal.
  • Optimize measured hotspots, not code that merely looks inefficient.

What It Cannot Catch

More tests do not automatically make a change safer. Tests with opaque assertions, unrealistic fixtures, or noisy failures can increase maintenance cost without helping the next developer fix the problem. Prefer failures that point directly at the broken contract.