karma-runner / karma-coverage

A Karma plugin. Generate code coverage.
MIT License
770 stars 247 forks source link

Blocks coverage is not reported in teamcity #246

Open kirill-onufrienko-db opened 8 years ago

kirill-onufrienko-db commented 8 years ago

In the build output I see karma coverage prints following summary

[19:22:57]Statements : 94.88% ( 2686/2831 ) [19:22:57]Branches : 88.19% ( 620/703 ) [19:22:57]Functions : 93.12% ( 798/857 ) [19:22:57]Lines : 94.93% ( 2601/2740 )

But in Teamcity Build summary I see only following numbers: Code coverage summary Methods: 93.1% 798/857 Lines: 94.9% 2601/2740

I think Block coverage could be shown here if it will be properly reported. As I understand this is the result of the following output: [19:22:58]##teamcity[buildStatisticValue key='CodeCoverageB' value='94.88'] [19:22:58]##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='798'] [19:22:58]##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='857'] [19:22:58]##teamcity[buildStatisticValue key='CodeCoverageM' value='93.12'] [19:22:58]##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='2601'] [19:22:58]##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='2740'] [19:22:58]##teamcity[buildStatisticValue key='CodeCoverageL' value='94.93']

Aa per

https://confluence.jetbrains.com/pages/viewpage.action?pageId=74847395#HowTo...-ImportcoverageresultsinTeamCity

You should not publish values CodeCoverageB, CodeCoverageL, CodeCoverageM, CodeCoverageC standing for block/line/method/class coverage percentage. TeamCity will calculate these values using their absolute parts. E.g. CodeCoverageL will be calculated as CodeCoverageAbsLCovered divided by CodeCoverageAbsLTotal. You could publish these values but in this case they will lack decimal parts and will not be useful.

MysticalLightObject commented 7 years ago

The underlying problem is in Istanbul, not the karma-coverage project. See https://github.com/gotwarlost/istanbul/blob/89e338fcb1c8a7dea3b9e8f851aa55de2bc3abee/lib/report/teamcity.js#L77

And there seems to be a pull request that somewhat fixes the issue: https://github.com/gotwarlost/istanbul/pull/680