jacoco插件添加

Posted on 2020-05-27 10:50  xiaotian1021  阅读(397)  评论(1编辑  收藏  举报

1.添加依赖

<dependency>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.8.3</version>
</dependency>

2.添加maven插件

<plugin>
	<groupId>org.jacoco</groupId>
	<artifactId>jacoco-maven-plugin</artifactId>
	<version>0.8.3</version>
	<configuration>
		<includes>
			<include>com/**/*</include>
		</includes>
	</configuration>
	<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>

3.在myeclipse中执行 maven install,在target下会出现jacoco文件:

|--site
  |----jacoco
    |----index.html
|--surefire-reports
|--jacoco.exec

可以打开index.html页面,可以看到测试覆盖率!

Copyright © 2024 xiaotian1021
Powered by .NET 8.0 on Kubernetes