
Sadly sometimes the coverage fails either fails to generate or the project might even fail to build. These tools may not work out of the box for your projects. There was no output in my case, but you can open target/cov/index.html and the report should be there: kcov HTML report Your mileage may vary
#CLION CODE COVERAGE INSTALL#
After you install the dependencies and cargo kcov runs successfully the coverage should be generated. Follow the prompts when you first run cargo kcov. Besides installing the package from crates.io, you will probably be required extra dependencies for this to work. Also, it integrates a customizable set of Clang-tidy checks.
#CLION CODE COVERAGE CODE#
# this will generate the tarpaulin-report.html in your rootįound at, install via cargo install cargo-kcov. CLion detects not only compilation errors but also code inefficiencies like unused variables or dead code. To generate the HTML report use the following: # generate the Html report In some cases (in other projects) this can also sadly fail with a segfault! In your project run cargo tarpaulin -v and everything goes well you should get some code coverage results right away: tarpaulin result In my case, I had to modify the Dockerfile to add extra dependencies that are required for the project. There’s a work in progress on macOS support, but at this time the best you can do in a non-Linux environment is to use the Docker image that tarpaulin provides. Keep in mind “Tarpaulin only supports x86_64 processors running Linux.” at this time. Installable like the rest of Rust utilities via cargo install cargo-tarpaulin.

It should produce a report like this for you: grcov html report Tarpaulin t html -llvm -branch -ignore-not-existing -o.


# grcov requires rust nightly at this time # Enable the required Rust flags to generate the coverage filesĮxport RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zno-landing-pads" The workflow for grcov is as follows: # Install the tool To produce HTML reports with grcov you can either use the built-in way or using the lcov package. To run the coverage select the directory that has your tests and using the context menu and use the “with Coverage” option: grcovĪnother tool for code coverage is called grcov. JetBrains CLionīefore we get into terminal tools that provide coverage, tools like CLion IDE provide a way to see code coverage right in the editor: CLion coverage panel A quick overview of some of the code coverage tools available for use with Rust lang today.
