最近项目中但愿加入javascript覆盖率统计,因为项目的单元测试用的google的jstd(javascript test driver),jstd生成<config filename>-coverage.dat LCOV 格式,这是一种linux上格式,在window上网上搜寻了好久没找到可用的maven组件。最后狠下心来本身写一个。代码已经放在github上,而且maven插件也成功release到官网。javascript
coverage 文件格式:java
项目主要采用java将coverage文件解析成java object在利用json序列化输出到固定位置的javascript文件。在利用angularjs显示文件覆盖率报表,利用bootstrap样式展现。linux
若是你对代码感兴趣,能够参考github源码,实例也在项目sample下。git
使用基本配置:angularjs
<plugin>github
<groupId>com.github.greengerong</groupId>json
<artifactId>JSCoverageReport</artifactId>bootstrap
<version>1.0</version>maven
<configuration>ide
<outputDirectory>${basedir}/build/</outputDirectory>
<coverageFile>${basedir}/build/jstd-coverage.dat</coverageFile>
<limit>60</limit>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
效果:
文件执行明细:
代码行之间的样式有点过于大,还没来得及修改样式,敬请原谅。