Madrapps / jacoco-report

Github action that publishes the JaCoCo report as a comment in the Pull Request
https://github.com/marketplace/actions/jacoco-report
MIT License
144 stars 63 forks source link

Misleading coverage difference #69

Closed arkadiuszpalka closed 11 months ago

arkadiuszpalka commented 1 year ago
For example, I increased the coverage but the output from the action: Module Coverage
:api 33.74% -3.65% :red_circle:

It is misleading that the difference in coverage is always expressed as a negative value when presented as a percentage, but I understand that you cannot calculate that difference between runs. I assume that the difference refers to the number of instructions missed in the changed files. How interpret this difference? To avoid any confusion, it might be helpful to include a brief explanation (legend) below the table.

function getCoverageDifference(overall: Coverage, changed: Coverage): number {
  const totalInstructions = overall.covered + overall.missed
  const missed = changed.missed
  return -(missed / totalInstructions) * 100
}
gokhan-oner commented 11 months ago

@arkadiuszpalka overall.covered + overall.missed -> this gives the current coverage of that file, including your changes. changed.missed is the missing coverage only caused by your changes. If its 0, it means you didn't introduced any non-covered instruction, so diff will be 0, if you introduced any new, it'll be greater than 0 & you'll get a - value. You're right that you might have tests that covers previously non-covered instructions but only way to get that is knowing the master branch coverage & it's not available. You can think it this way, You introduced some new instruction & didn't covered %3.65 of them, compared to total # of instructions

arkadiuszpalka commented 11 months ago

Thank you for the clear explanation. I missed such a note under the table