Code coverage statistics and diff view

Answered

Hi! I am working in a team tasked with building a plugin that can help users run a sort of "diff" coverage view on the source code for two subsequent runs. The idea is that they can use a current test suite to get a coverage report on some file (like the default one that shows lines covered in green etc). They can then modify their test suite in order to hopefully increase coverage. Then they will be shown the previous view on the left and the new run report on the right in somewhat of a diff view so that its easy for them to analyze if the test they wrote did what they expected. I also want to add some statistics such as "lines newly covered in the new run", "lines covered before but not by the latest run" etc

I haven't been able to find any way to integrate coverage report functionality in order to somehow fetch this report for a class (or file) using an action in my plugin. I looked into CoverageRunner and CoverageEngine but noticed that there is nothing specific for java and thought that maybe this was intended for custom languages instead. I would greatly appreciate any pointers on coverage reports using plugins. Any existing plugin source code that does something similar would also be great!

1 comment
Comment actions Permalink

Each coverage run saves `com.intellij.rt.coverage.data.ProjectData`. You can listen to the events through `com.intellij.coverage.CoverageSuiteListener`.

(`com.intellij.coverage.CoverageSuitesBundle#getCoverageData` gives you current coverage data.)

Coverage reports are custom to runners and may be different e.g. for IDEA runner and JaCoCo. So I'd rather advise to check raw data instead of reports instead

Anna

0

Please sign in to leave a comment.