zoukankan      html  css  js  c++  java
  • 解决sonar单元测试覆盖率为0的问题

    pom.xml中添加jacoco插件

    <plugin>
       <groupId>org.jacoco</groupId>
       <artifactId>jacoco-maven-plugin</artifactId>
       <version>0.7.9</version>
       <configuration>
          <classDumpDir>target/classes</classDumpDir>
          <includes>
             <include>com///**</include>
          </includes>
       </configuration>
       <executions>
          <execution>
             <id>default-prepare-agent</id>
             <goals>
                <goal>prepare-agent</goal>
             </goals>
          </execution>
          <execution>
             <id>default-prepare-agent-integration</id>
             <goals>
                <goal>prepare-agent-integration</goal>
             </goals>
          </execution>
          <execution>
             <id>default-report</id>
             <goals>
                <goal>report</goal>
             </goals>
          </execution>
          <execution>
             <id>default-report-integration</id>
             <goals>
                <goal>report-integration</goal>
             </goals>
          </execution>
          <execution>
             <id>report-aggregate</id>
             <phase>verify</phase>
             <goals>
                <goal>report-aggregate</goal>
             </goals>
          </execution>
          <execution>
             <id>default-merge</id>
             <goals>
                <goal>merge</goal>
             </goals>
          </execution>
       </executions>
    </plugin>

    <build>
        <plugins>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.7.8</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    执行单元测试命令:mvn test

    结果在target目录下生产jacoco.exec文件,表明jacoco正确执行


    执行sonar命令:mvn sonar:sonar -Dsonar.host.url=http://localhost:9000 -Dsonar.login=[yours id]

    链接:https://my.oschina.net/u/2274056/blog/3211734

  • 相关阅读:
    GoCN每日新闻(2019-10-14)
    GoCN每日新闻(2019-10-13)
    GoCN每日新闻(2019-10-12)
    GoCN每日新闻(2019-10-11)
    [xms]西软xms试算平衡报表-穿透明细报表-增加储值卡卡号列
    GoCN每日新闻(2019-10-10)
    GoCN每日新闻(2019-10-09)
    GoCN每日新闻(2019-10-08)
    GoCN每日新闻(2019-10-07)
    [golang]Golang实现高并发的调度模型---MPG模式
  • 原文地址:https://www.cnblogs.com/linyouyi/p/13559750.html
Copyright © 2011-2022 走看看