最近項目中但願加入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>
效果:
文件執行明細:
代碼行之間的樣式有點過於大,還沒來得及修改樣式,敬請原諒。