解决sonar单元测试覆盖率为0的问题

社会主义新天地 提交于 2020-03-26 11:07:29

3 月,跳不动了?>>>

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>

执行单元测试命令:mvn test

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


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!