CtrlK
BlogDocsLog inGet started
Tessl Logo

testland/cargo-test

Configures and runs Rust's built-in `cargo test` - `#[test]` + `#[should_panic]` + `Result<(), E>` returns; integration tests in `tests/`; doc-tests embedded in `///` comments; `--lib` / `--bins` / `--all-targets` / `--workspace` selection; `cargo bench` (nightly) + Criterion (stable); `cargo test -- --test-threads=1` for serial; `cargo test -- --nocapture` to see println output. Use for any Rust project - testing is built into Cargo, no install needed.

75

Quality

94%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide

SecuritybySnyk

Passed

No findings from the security scan

Overview
Quality
Evals
Security
Files

coverage-and-benchmarks.mdreferences/

Coverage and benchmarks

Measurement tooling for cargo test. Both need an extra crate installed; neither ships in the stdlib test harness.

Coverage

Stable Rust support via cargo-tarpaulin (Linux) or cargo-llvm-cov (cross-platform):

# llvm-cov (recommended for cross-platform)
cargo install cargo-llvm-cov
cargo llvm-cov --html              # HTML report
cargo llvm-cov --lcov --output-path coverage.lcov
cargo llvm-cov --fail-under-lines 80   # gate at 80%

# Or tarpaulin (Linux-only)
cargo install cargo-tarpaulin
cargo tarpaulin --out html --output-dir coverage/

Benchmarks

Stable: use Criterion (mature, ergonomic):

cargo install cargo-criterion
# Cargo.toml
[dev-dependencies]
criterion = "0.5"

[[bench]]
name = "math_bench"
harness = false
// benches/math_bench.rs
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use my_crate::math::add;

fn bench_add(c: &mut Criterion) {
    c.bench_function("add 1 2", |b| b.iter(|| add(black_box(1), black_box(2))));
}

criterion_group!(benches, bench_add);
criterion_main!(benches);
cargo bench
# Or via criterion CLI for richer reports:
cargo criterion

Nightly Rust has built-in #[bench] (cargo +nightly bench); not recommended for CI (requires nightly toolchain).

Sources

  • crates.io/crates/cargo-llvm-cov - coverage tool
  • bheisler.github.io/criterion.rs - Criterion docs

SKILL.md

tile.json