EvoSuite是由Sheffield等大學聯合開發的一種開源工具,用於自動生成測試用例集,生成的測試用例均符合Junit的標準,可直接在Junit中運行。獲得了Google和Yourkit的支持。bash
隨着單元測試的AI化,衡量單元測試的標準變得尤爲重要,那麼分析單元測試的代碼覆蓋率是一種行之有效的方法。Cobertura 是一種開源工具,它經過檢測基本的代碼,並觀察在測試包運行時執行了哪些代碼和沒有執行哪些代碼,來測量測試覆蓋率。Cobertura提供了Ant和Maven的執行方式,而且Cobertura要比JaCoCo配置和使用起來更方便。maven
EvoSuite能夠和Cobertura無縫集成,只須要在配置文件中加入以下配置,就能夠了(在平行於build下):工具
<reporting> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.7</version> </plugin> </plugins> </reporting>複製代碼
同時須要在build的插件中加入單元測試
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.7</version> <configuration> <instrumentation> <ignores> <ignore>com.example.boringcode.*</ignore> </ignores> <excludes> <exclude>com/example/dullcode/**/*.class</exclude> <exclude>com/example/**/*Test.class</exclude> </excludes> </instrumentation> </configuration> <executions> <execution> <goals> <goal>clean</goal> </goals> </execution> </executions> </plugin>複製代碼
就能夠在MavenProjects插件中看到Cobertura的使用插件了。測試
其中:ui
cobertura:help 檢查cobertura插件的幫助(也能夠check配置是否是正確)cobertura:clean 狀況cobertura運行結果cobertura:check 運行cobertura的檢測任務cobertura:cobertura 運行cobertura的檢查任務並生產報告,報告在/target/site/cobertura下cobertura:dump-datafile cobertura的datafile dump Mojocobertura:instrument 檢查編譯過的classes複製代碼