Jacoco是一个开源的Java代码覆盖率工具,Jacoco可以嵌入到Ant 、Maven中,并提供了EclEmma Eclipse插件,也可以使用JavaAgent技术监控Java程序。很多第三方的工具提供了对Jacoco的集成,如sonar、Jenkins等。
打开Eclipse,File->New->Project->Maven Project,新建一个Maven工程~
点击“Next”按钮,然后填写groupId和artifactId信息后点击"Finish"按钮即可~
groupId --> com.xxx.tutorial
artifactId --> jacoco-demo
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-compiler-pluginartifactId>
<version>3.6.1version>
<configuration>
<skipMain>trueskipMain>
<skip>trueskip>
<source>1.7source>
<target>1.7target>
configuration>
plugin>
<plugin>
<groupId>org.jacocogroupId>
<artifactId>jacoco-maven-pluginartifactId>
<version>${jacoco.version}version>
<executions>
<execution>
<id>prepare-agentid>
<goals>
<goal>prepare-agentgoal>
goals>
execution>
<execution>
<id>reportid>
<phase>prepare-packagephase>
<goals>
<goal>reportgoal>
goals>
execution>
<execution>
<id>post-unit-testid>
<phase>testphase>
<goals>
<goal>reportgoal>
goals>
<configuration>
<dataFile>target/jacoco.execdataFile>
<outputDirectory>target/jacoco-utoutputDirectory>
configuration>
execution>
executions>
<configuration>
<systemPropertyVariables>
<&
声明:所有来源为“澳门太阳集团城网址8722”的内容信息,未经本网许可,不得转载!如对内容有异议或投诉,请与我们联系。邮箱:marketing@think-land.com