codeclimate / test-reporter

Code Climate Test Reporter
MIT License
156 stars 76 forks source link

Feature request: add branch coverage option for lcov formatter #389

Open ArSn opened 5 years ago

ArSn commented 5 years ago

I am running code coverage reporting for JavaScript with the lcov formatter by using Istanbuls nyc CLI tool as is explained in the docs. While this works just great with the test reporter as it supports lcov, the test reporter is reporting the percentage of lines that were covered by running the tests.

However, some people (like me) would rather like to have the branch coverage reported as a percentage, in order to be even more thorough with their test coverage. To make this possible, it would be great to add an option to make the test reporter do just that.

As far as I understood by the geninfo manpage for lcov, the branch data is in the lcov.info file with the BRDA, BRF and BRH prefixes, which is already created by nyc.

That being said, I presume that the requirements to achieve this are already available and it would "only" have to be implemented in formatters/lcov/lcov.go.

wfleming commented 5 years ago

Altering the lcov formatter in this repo might be technically sufficient to report only branch coverage to our API, but I'm not sure that would result in very useful behavior with the test coverage results on our site. The trend charts we display and per-file test coverage information we display on the site were all built with line-by-line coverage in mind, without regard to what any particular line means. That said, it might be acceptable for you if you're ok with some of the displays on the site using the test coverage data perhaps seeming a bit off.

This might actually be cleaner to implement as a separate script rather than plumbing all the necessary pieces through the test-reporter. Have you considered protoyping this as a preprocessing script that would remove non-branch information from the lcov.info and reformatting the branch-focused prefixes to the prefixes we normally look for? If you did that and tried it I think you might be able to get what you're after and see how it would work with our website.