zoukankan      html  css  js  c++  java
  • 怎么实现在jenkens页面配置sonar,以及如何利用cobertura插件实现sonar页面显示测试覆盖率

          最近我在工作中遇到需要给项目中每个模块配置Sonarqube,来看看测试用例覆盖的情况。在这个过程中遇到了一些问题,也查了很多资料。现在记录一下具体应该怎么配置。

          先展示一下实现的效果:

          

                           图一

    It will show:

                                                                     图二

    现在来看看具体配置:

    要enable Sonarqube, 需在 job --> configure --> Post-build Actions 配置Branch 和 JDK 信息:

                                                                           图三

    配置好了以后,SonarQube 可以在页面上显示出来了,点击进去,效果图:【与图二相比,缺少了Coverage信息】

                                                                       图四

    如何利用cobertura插件实现sonar页面显示测试覆盖率:

    需要在pom.xml文件中配置一下信息:

    <plugin>
      <groupId>org.codehaus.sonar</groupId>
      <artifactId>sonar-maven3-plugin</artifactId>
      <version>3.5</version>
    </plugin>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>cobertura-maven-plugin</artifactId>
      <version>2.6</version>
      <configuration>
        <formats>
          <format>xml</format>
          <format>html</format>
        </formats>
        <aggregate>true</aggregate>
        <instrumentation>
          <includes>
            <include>**/*.class</include>
          </includes>
        </instrumentation>
      </configuration>
      <executions>
        <execution>
          <id>clean</id>
          <phase>pre-site</phase>
          <goals>
            <goal>clean</goal>
          </goals>
        </execution>
        <execution>
          <id>instrument</id>
          <phase>site</phase>
          <goals>
            <goal>instrument</goal>
            <goal>cobertura</goal>
          </goals>
        </execution>
      </executions>
    </plugin>

    并在job --> configure --> Build 配置  Goals and options:

                                                                                        图五

    保存配置,重新build这个job,就行了。

  • 相关阅读:
    Linux学习笔记:使用prompt关闭ftp中mget和mput的确认提醒
    Linux学习笔记:ftp中binary二进制与ascii传输模式的区别
    Linux学习笔记:使用ftp命令上传和下载文件
    Linux学习笔记:scp远程拷贝文件
    MySQL学习笔记:一道group by+group_concat解决的小问题
    MySQL学习笔记:select语句性能优化建议
    Excel学习笔记:if({1,0})用法
    vim加亮和自动缩进
    linux的chown命令
    oracle环境变量
  • 原文地址:https://www.cnblogs.com/Jenny22/p/6484425.html
Copyright © 2011-2022 走看看