testJococ demo
前提: mvn项目
步骤:
1。 pom文件:
<dependency> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.8.4</version> </dependency>
<build> <pluginManagement> <plugins> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.8.4</version> <executions> <execution> <id>pre-test</id> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>post-test</id> <phase>test</phase> <goals> <goal>report</goal> </goals> </execution> </executions> </plugin> </plugins> </pluginManagement> </build>
运行:
1. mvn clean test org.jacoco:jacoco-maven-plugin:0.8.4:prepare-agent install
2. mvn jacoco:report