<tfoot id='13vh7'></tfoot>

    <legend id='13vh7'><style id='13vh7'><dir id='13vh7'><q id='13vh7'></q></dir></style></legend>
    <i id='13vh7'><tr id='13vh7'><dt id='13vh7'><q id='13vh7'><span id='13vh7'><b id='13vh7'><form id='13vh7'><ins id='13vh7'></ins><ul id='13vh7'></ul><sub id='13vh7'></sub></form><legend id='13vh7'></legend><bdo id='13vh7'><pre id='13vh7'><center id='13vh7'></center></pre></bdo></b><th id='13vh7'></th></span></q></dt></tr></i><div id='13vh7'><tfoot id='13vh7'></tfoot><dl id='13vh7'><fieldset id='13vh7'></fieldset></dl></div>

        <small id='13vh7'></small><noframes id='13vh7'>

          <bdo id='13vh7'></bdo><ul id='13vh7'></ul>

        “没有关于每次测试覆盖率的信息."来自 Sonar 和 Jacoco Ant 构建

        时间:2024-05-09
          <tbody id='I8gtd'></tbody>
        <i id='I8gtd'><tr id='I8gtd'><dt id='I8gtd'><q id='I8gtd'><span id='I8gtd'><b id='I8gtd'><form id='I8gtd'><ins id='I8gtd'></ins><ul id='I8gtd'></ul><sub id='I8gtd'></sub></form><legend id='I8gtd'></legend><bdo id='I8gtd'><pre id='I8gtd'><center id='I8gtd'></center></pre></bdo></b><th id='I8gtd'></th></span></q></dt></tr></i><div id='I8gtd'><tfoot id='I8gtd'></tfoot><dl id='I8gtd'><fieldset id='I8gtd'></fieldset></dl></div>
          <tfoot id='I8gtd'></tfoot>

            <small id='I8gtd'></small><noframes id='I8gtd'>

              <bdo id='I8gtd'></bdo><ul id='I8gtd'></ul>
              • <legend id='I8gtd'><style id='I8gtd'><dir id='I8gtd'><q id='I8gtd'></q></dir></style></legend>

                  本文介绍了“没有关于每次测试覆盖率的信息."来自 Sonar 和 Jacoco Ant 构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 Ant、Jacoco 和 Sonar.当我运行我的构建时,Sonar 告诉我没有关于每次测试覆盖率的信息".和声纳仪表板有我的覆盖结果,但我无法深入了解它们以查看代码.但是,Jacoco 生成的 HTML 报告确实包含深入代码.这是我的报道任务:

                  I'm using Ant, Jacoco and Sonar. When I run my build Sonar tells me that "No information about coverage per test." and the Sonar dashboard has my coverage results, but I cannot drill down into them to see the code. However, the HTML report generated by Jacoco does include drill down into the code. This is my coverage task:

                      <jacoco:coverage destfile="${coverage.output.file}" >
                          <junit printsummary="on" 
                              errorProperty="test.failed" 
                              failureProperty="test.failed" 
                              haltonfailure="yes" 
                              fork="true">
                              <formatter type="brief" usefile="false" />
                              <formatter type="xml" />
                              <classpath>
                                  <path refid="test.build.class.path"/>
                                  <pathelement location="${test.bin.dir}"/>       
                              </classpath>
                              <batchtest todir="${results.dir}">
                                  <fileset dir="${test.bin.dir}">
                                      <include name = "**/**/*Test.class"/>
                                  </fileset>
                              </batchtest>
                          </junit>
                      </jacoco:coverage>  
                  
                      <jacoco:report>
                          <executiondata>
                              <file file="${coverage.output.file}"/>
                          </executiondata>
                          <structure name="${ant.project.name}">
                              <classfiles>
                                  <fileset dir="${bin.dir}"/>
                              </classfiles>
                              <sourcefiles encoding="UTF-8">
                                  <fileset dir="${src.dir}"/>
                              </sourcefiles>
                          </structure>
                          <html destdir="${coverage.results.dir}"/>
                      </jacoco:report>
                  </target>
                  

                  我的声纳目标看起来像这样:

                  And my Sonar target looks like this:

                  <target name="sonar" depends = "run">
                      <property name="sonar.jdbc.url" value="..." />
                      <property name="sonar.jdbc.username" value="...r" />
                      <property name="sonar.jdbc.password" value="..." />
                  
                      <property name="sonar.projectKey" value="org.codehaus.sonar:example-java-ant" />
                      <property name="sonar.projectName" value="${ant.project.name} (ant)" />
                      <property name="sonar.projectVersion" value="1.0" />
                      <property name="sonar.language" value="java" />
                      <property name="sonar.sources" value="${src.dir}" />
                      <property name="sonar.binaries" value="${bin.dir},${test.bin.dir}" />
                      <property name="sonar.libraries" value="${lib.dir}/*.jar" />    
                  
                      <property name="sonar.dynamicAnalysis" value="reuseReports" />
                      <property name="sonar.surefire.reportsPath" value="${results.dir}" />
                      <property name="sonar.java.coveragePlugin" value="jacoco" />
                      <property name="sonar.jacoco.reportPath" value="${coverage.output.file}" />
                  
                      <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
                           <classpath>         
                              <fileset dir="${lib.dir}" includes="sonar-ant-task-2.0.jar"/>
                           </classpath>
                      </taskdef>   
                  
                      <sonar:sonar />     
                  </target>
                  

                  有人知道我错过了什么吗?

                  Does anyone know what I am missing?

                  推荐答案

                  sonar.test 属性应该设置为测试类.我们的 maven pom 中有以下内容.对于 ANT,您可以执行类似的操作:

                  The sonar.test property should be set to the test-classes. We have the following in our maven pom. For ANT you do something similar:

                      <profile>
                          <id>sonarprofile</id>
                          <activation>
                              <activeByDefault>true</activeByDefault>
                          </activation>
                          <properties>
                              <sonar.host.url>....our host..../sonar.host.url>
                              <sonar.projectKey>....our key....</sonar.projectKey>
                              <sonar.projectName>${project.artifactId}</sonar.projectName>
                              <sonar.projectVersion>${project.version}</sonar.projectVersion>
                              <sonar.language>java</sonar.language>
                              <sonar.sources>src/main/java</sonar.sources>
                              <!-- sonar.tests>target/test-classes</sonar.tests -->
                              <!-- that is the default location for Maven projects and -->
                              <!-- this parameter can't actually be set in that case -->
                              <sonar.scm.provider>git</sonar.scm.provider>
                              <sonar.login>${SONAR_LOGIN}</sonar.login>
                              <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
                              <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
                              <sonar.jacoco.reportPath>${basedir}/target/coverage-reports/jacoco-unit.exec</sonar.jacoco.reportPath>
                          </properties>
                      </profile>
                  

                  顺便说一句,这里还使用了一些其他属性:

                  Incidently there are some other properties being used in this:

                  • 我通过我的声纳用户生成了一个 SONAR 令牌,而不是使用登录名和密码
                  • JaCoCo 覆盖范围是使用 jacoco-maven-plugin 单独生成的,而 sonar.jacoco.reportPath 是该插件中使用的属性.
                  • I've generated a SONAR token through my sonar user rather than use login and password
                  • JaCoCo coverage is being generated separately using the jacoco-maven-plugin and the sonar.jacoco.reportPath is a property used in that plugin.

                  David Racodon 的回答 (https://stackoverflow.com/a/16645108/1019307) 曾经是正确的,但在2014 年年中,SonarQube 停止执行测试作为声纳执行的一部分 (http://www.sonarqube.org/unit-test-execution-in-sonarqube/).因此,为什么指向测试源不再有效.

                  David Racodon's answer (https://stackoverflow.com/a/16645108/1019307) was once correct but in mid-2014 SonarQube stopped executing the tests as part of the sonar execution (http://www.sonarqube.org/unit-test-execution-in-sonarqube/). Hence why pointing to the test source no longer works.

                  这篇关于“没有关于每次测试覆盖率的信息."来自 Sonar 和 Jacoco Ant 构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:SonarQube 分析成功但未被服务器处理 下一篇:SonarQube 是否支持 Java9?

                  相关文章

                    <legend id='aCYqO'><style id='aCYqO'><dir id='aCYqO'><q id='aCYqO'></q></dir></style></legend>

                    • <bdo id='aCYqO'></bdo><ul id='aCYqO'></ul>

                    1. <small id='aCYqO'></small><noframes id='aCYqO'>

                      <i id='aCYqO'><tr id='aCYqO'><dt id='aCYqO'><q id='aCYqO'><span id='aCYqO'><b id='aCYqO'><form id='aCYqO'><ins id='aCYqO'></ins><ul id='aCYqO'></ul><sub id='aCYqO'></sub></form><legend id='aCYqO'></legend><bdo id='aCYqO'><pre id='aCYqO'><center id='aCYqO'></center></pre></bdo></b><th id='aCYqO'></th></span></q></dt></tr></i><div id='aCYqO'><tfoot id='aCYqO'></tfoot><dl id='aCYqO'><fieldset id='aCYqO'></fieldset></dl></div>
                      <tfoot id='aCYqO'></tfoot>