cargo-testdox

Crates.iocargo-testdox
lib.rscargo-testdox
version0.2.1
sourcesrc
created_at2024-08-10 17:53:27.474417
updated_at2024-09-08 13:44:04.170925
descriptionA Cargo subcommand to print your test names as sentences.
homepagehttps://github.com/bitfield/cargo-testdox
repositoryhttps://github.com/bitfield/cargo-testdox
max_upload_size
id1332587
size75,417
John Arundel (bitfield)

documentation

https://docs.rs/cargo-testdox

README

Crate Docs CI Audit Maintenance

cargo-testdox

A Cargo subcommand to print your Rust test names as sentences.

Installation

cargo install cargo-testdox

Usage

In any Rust project with tests, run:

cargo testdox

Animated demo

cargo-testdox will first invoke cargo test to run your tests, with any extra arguments that you give it. It will then show the result for each test (passed, failed, or ignored), with the test name formatted as a sentence. That is, with underscores replaced by spaces.

For example, the following test:

#[test]
fn it_works() {}

will produce this output when run with cargo-testdox:

 ✔ it works

If the test were failing, it would produce:

 x it works

If the test were ignored, it would produce:

 ? it works

Doctests are ignored, since they can't currently be named (pending RFC #3311).

Function names with underscores

To avoid underscores in a snake-case function name from being replaced, put _fn_ after the function name:

#[test]
fn print_hello_world_fn_prints_hello_world() {}

becomes:

✔ print_hello_world prints hello world

Why

Because test names should be sentences.

Compare gotestdox, a similar tool for Go tests.

Commit count: 0

cargo fmt