• (003)maven项目使用jacoco测试单元覆盖率


      直奔主题,在项目的pom.xml中配置插件:

    <!-- 覆盖率 -->
    <plugin>
      <groupId>org.jacoco</groupId>
      <artifactId>jacoco-maven-plugin</artifactId>
      <version>0.8.1</version>
      <executions>
        <execution>
          <id>prepare-agent</id>
          <goals>
            <goal>prepare-agent</goal>
          </goals>
        </execution>
        <execution>
          <id>report</id>
          <phase>prepare-package</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
          <execution>
            <id>post-unit-test</id>
            <phase>test</phase>
            <goals>
              <goal>report</goal>
            </goals>
            <configuration>
              <dataFile>target/jacoco.exec</dataFile>
            </configuration>
        </execution>
      </executions>
    </plugin>

      运行:

    mvn test

      查看覆盖率:项目/target/site/jacoco/index.html,双击打开,点击每一条可逐级进入。

      

  • 相关阅读:
    一月5日
    使用Jenkins部署SpringBoot
    SpringBoot +Jpa +Thymeleaf 增删改查示例
    SpringBoot 整合 Shiro ——登录认证和权限管理
    SpringBoot 小技巧
    SpringBoot 如何测试打包部署
    SpringBoot 中MongDB的使用
    定时任务
    RabbitMQ详解
    Mybatis多数据源最简单解决方案
  • 原文地址:https://www.cnblogs.com/javasl/p/12843568.html
Copyright © 2020-2023  润新知