question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Code coverage not working

See original GitHub issue

Environment

  • IntelliJ Rust plugin version: 0.2.115.2157-193
  • Rust toolchain version: rustc 1.41.0-nightly (710a362dc 2019-12-05)
  • IDE name and version: CLion 2019.3.4
  • Operating system: Linux Arch
  • gcov: gcov (Arch Linux 9.2.1+20200130-2) 9.2.1 20200130
  • lcov: LCOV version 1.14-6-g40580cd
  • grcov: grcov 0.5.5

Problem description

Code coverage does not work

Steps to reproduce

Create a project with two files:

Cargo.toml

[package]
name = "rust-coverage-clion"
version = "0.1.0"
edition = "2018"

[dependencies]

lib.rs

fn sum(a: u32, b: u32) -> u32 {
    dbg!((a, b));
    a + b
}


#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn it_works() {
        assert_eq!(sum(2, 2), 4);
    }
}

Add a run configuration “test” of type “Cargo command”, where command is “test”

Click on “Run ‘test’ with coverage”

CLion successfully build the project and launches test. Test results are visible (one test, it succeeds) and dbg! output is shown as expected.

Code Coverage is not highlighted in the gutter.

Clicking “Run -> Show code coverage data” shows a window with a message “no coverage suites configured”

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
mleonhardcommented, Jun 25, 2021

The fix was to update grcov:

$ cargo install --force grcov
...
Replaced package `grcov v0.5.15` with `grcov v0.7.1` (executable `grcov`)
1reaction
mleonhardcommented, Mar 17, 2021

Code coverage is not working for me with Rust plugin 0.3.143.3737-203 in CLion 2020.3.3. My project uses a cargo workspace. When I click the Coverage button, the tests run but the coverage screen does not appear.

I made these changes to the Run Configuration:

  • Command: test --package package1
  • Working directory: the workspace directory, not the package directory

Now the coverage screen appears, but all files show 0 lines covered.

I filed an issue with JetBrains: https://youtrack.jetbrains.com/issue/CPP-24459

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Code Coverage - Visual Studio (Windows)
Possible reasons for seeing no results or old results · Do you have the right edition of Visual Studio? · No tests were...
Read more >
Code Coverage Not Showing In Editor - Apple Developer
I have turned on code coverage (before running my unit tests), and clicked on Editor > Show Code Coverage, but the editor does...
Read more >
Code Coverage Results Window cannot be shown from Menu ...
The only way to open the Window is to to go Test Explorer, right click a test, and Analyze Code Coverage. After that...
Read more >
Why does the Code Coverage not work in VS?
To analyze the code coverage of unit tests in Visual Studio you will typically select a set of tests and execute Analyse Code...
Read more >
How to fix issue of code coverage not finding functions when ...
When running code coverage 4 fail due to functions being 'not defined'. They are defined (as the tests clearly show when they pass)....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found