sinkcup / coverage-badge

create badge from test coverage reports
https://www.npmjs.com/package/test-coverage-badge
MIT License
0 stars 0 forks source link

解析 clover 覆盖率 #5

Closed sinkcup closed 3 years ago

sinkcup commented 3 years ago

PHPUnit、jest 都可以生成 clover xml

<coverage generated="1636543368">
<project timestamp="1636543368">
<file name="api-php/app/Console/Kernel.php">
...
</file>
<metrics files="36" loc="1328" ncloc="772" classes="25" methods="38" coveredmethods="21" conditionals="0" coveredconditionals="0"
 statements="97"
 coveredstatements="54"
 elements="135" coveredelements="75"/>
</project>
</coverage>

对比 PHPUnit text 格式可知:行覆盖率是 coveredstatements / statements

Code Coverage Report:
2021-11-10 10:14:16

Summary:
Classes: 48.00% (12/25) Methods: 55.26% (21/38) Lines: 55.67% (54/97) ...

sinkcup commented 3 years ago

发现一个坑:clover xml 没有直接汇总 class 覆盖率,而是要根据 <file /> 计算,很麻烦,这个需求不重要,暂时不做。