SupercovDocumentation

Documentation

Rust test coverage

Set up Supercov with your agent, or run it yourself with Cargo tests.

Rust

Ask your coding agent to set up Supercov in your project:

Install Supercov with cargo install supercov. Read supercov docs and check
the supported Rust toolchain before running our existing Cargo tests.
Follow supercov docs assertion-agent to build and validate the assertion map.
Show the coverage report and any measurement limits. Don't change
application code or tests.

Run it yourself

The supported measurement toolchain is Rust 1.95. Use it for these commands; installing Supercov doesn’t change your project’s selected toolchain.

cargo install supercov
supercov --version

Installation builds the CLI from source and can take a few minutes. Make sure Cargo’s binary directory is on your PATH. You don’t need Node.js.

Run your tests

From your crate or workspace root:

supercov -- cargo test

Keep the flags your project normally uses. For a workspace or nextest suite:

supercov -- cargo test --workspace
supercov -- cargo nextest run --workspace

Supercov tracks individual Cargo tests and rustdoc doctests. It also supports cargo-nextest 0.9.138 and 0.9.140, including retries. Your test filters and runner options still apply.

Inspect the run:

supercov runs latest
supercov runs latest gaps --limit 5

Try a small example

Download the examples, extract them, and open supercov-examples/rust. It is a small crate with no third-party dependencies and two integration tests.

In src/lib.rs, checkout requires a signed-in customer and an unexpired session:

pub struct Order { pub status: &'static str, pub total: i32 }
pub fn checkout(signed_in: bool, expired: bool, price: i32, quantity: i32) -> Order {
    if signed_in && !expired {
        let total = price * quantity;
        return Order { status: "confirmed", total };
    }
    Order { status: "denied", total: 0 }
}

The tests cover a valid order and a signed-out visitor. From the example folder:

supercov -- cargo test
supercov runs latest

The coverage section recorded with Supercov 0.0.48 is:

Coverage
  Lines      100.00% (11/11)
  Branches   100.00% (6/6)
  MC/DC      50.00% (1/2)

This run also measures integration-test code, so its line count includes more than src/lib.rs. To inspect the checkout decision specifically:

supercov runs latest decision src/lib.rs:3

The report includes:

signed_in && !expired
C1 covered: signed_in
C2 MISSING: !expired

No test checks a signed-in customer with an expired session. Adding that test raises MC/DC to 100% in the recorded run. See MC/DC for how to read the result.

Check what the tests assert

These tests check order.status, but not order.total. Adding assert_eq!(order.total, 50) would check the calculation for this input.

The setup prompt asks your agent to map assertions to the code they check. Supercov checks the map against execution and passing assertions in the same test. The assertion guide explains the score and why some statements, including test code, may remain unmapped.

Rust-specific limits

Supercov measures modules rustc compiles, not every .rs file in the directory. Const contexts and macro expansions have measurement limits. cross isn’t supported. See runner support for details.

Already using cargo-llvm-cov or Tarpaulin? See how the reports differ. supercov docs coverage-model prints the guide for your installed version.