cargo-cov: Source coverage for Rustcargo-cov is a cargo subcommand which performs source coverage collection and reporting for Rust crates. cargo-cov
utilizes LLVM's gcov-compatible profile generation pass, and supports a lot of platforms.
You may install cargo-cov via cargo.
cargo install cargo-cov
The typical workflow is like this:
# clean up previous coverage result
cargo cov clean
# test the code
cargo cov test
# open the coverage report
cargo cov report --open
We strongly recommend you use nightly Rust since only the nightly toolchain has built-in instrumented profiling support
via -Zprofile.
If you must use a stable toolchain, you may try the following:
Install the compiler-rt profile library.
| Target | Instruction |
|---|---|
| Ubuntu, Debian | Install libclang-common-7-dev, or simply install clang |
| Fedora | Install compiler-rt |
| OpenSUSE | Install llvm-clang |
| Windows (MSVC) | Install Clang for Windows Pre-Built Binary from LLVM |
| macOS, iOS | Provided by the Xcode command line tools |
| Android | Provided by Android NDK |
Execute the doc-test separately from the normal tests. Run the doc-test before the normal tests.
# Run --doc tests before other things before 1.19
cargo cov test --doc
cargo cov test --lib
We do not guarantee that a correct coverage profile will be generated using this method.
Rust
85.2%
JavaScript
8.1%
HTML
3.7%
Python
1.5%
CSS
1.4%
cargo-cov: Source coverage for Rustcargo-cov is a cargo subcommand which performs source coverage collection and reporting for Rust crates. cargo-cov
utilizes LLVM's gcov-compatible profile generation pass, and supports a lot of platforms.
You may install cargo-cov via cargo.
cargo install cargo-cov
The typical workflow is like this:
# clean up previous coverage result
cargo cov clean
# test the code
cargo cov test
# open the coverage report
cargo cov report --open
We strongly recommend you use nightly Rust since only the nightly toolchain has built-in instrumented profiling support
via -Zprofile.
If you must use a stable toolchain, you may try the following:
Install the compiler-rt profile library.
| Target | Instruction |
|---|---|
| Ubuntu, Debian | Install libclang-common-7-dev, or simply install clang |
| Fedora | Install compiler-rt |
| OpenSUSE | Install llvm-clang |
| Windows (MSVC) | Install Clang for Windows Pre-Built Binary from LLVM |
| macOS, iOS | Provided by the Xcode command line tools |
| Android | Provided by Android NDK |
Execute the doc-test separately from the normal tests. Run the doc-test before the normal tests.
# Run --doc tests before other things before 1.19
cargo cov test --doc
cargo cov test --lib
We do not guarantee that a correct coverage profile will be generated using this method.
Rust
85.2%
JavaScript
8.1%
HTML
3.7%
Python
1.5%
CSS
1.4%