<bdo id='BSvW8'></bdo><ul id='BSvW8'></ul>

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

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

        <tfoot id='BSvW8'></tfoot>

      1. 将 JaCoCo 与 SONAR 集成以实现单元和集成测试覆盖率

        Integrating JaCoCo with SONAR for unit and integration test coverage(将 JaCoCo 与 SONAR 集成以实现单元和集成测试覆盖率)

        <tfoot id='UrfiE'></tfoot>

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

          <bdo id='UrfiE'></bdo><ul id='UrfiE'></ul>
            <tbody id='UrfiE'></tbody>
              1. <small id='UrfiE'></small><noframes id='UrfiE'>

                • 本文介绍了将 JaCoCo 与 SONAR 集成以实现单元和集成测试覆盖率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有没有人尝试过配置 JaCoCo 以将单元和集成测试的覆盖率转储到 2 个不同的文件中,以便 SONAR 使用它们,使用 ANT 构建?

                  Has any one tried configuring JaCoCo to dump the coverage of unit and integration tests in 2 different files, for SONAR to use them, using ANT build?

                  推荐答案

                  这是一个可行的解决方案,为单元测试和集成测试生成报告.此解决方案使用 append 策略.

                  Here is a working solution, generating the report for both unit tests and integration tests. This solution is using the append strategy.

                  请注意,为了在 apply 策略上正常工作,阶段应按顺序执行(如果 mvn testmvn verify -DskipUnitTests 将并行执行,可能无法正常工作).

                  Please note that in order to work properly on the apply strategy, the phases should be executed sequentially (if the mvn test and mvn verify -DskipUnitTests will be executed in parallel there is possible to not work fine).

                  <plugin>
                      <groupId>org.jacoco</groupId>
                      <artifactId>jacoco-maven-plugin</artifactId>
                      <version>${jacoco.version}</version>
                  
                      <configuration>
                          <skip>${skipTests}</skip>
                  
                          <!-- This line is very important, because allows to append the results to the `jacoco_aggregation.exec` report. -->
                          <append>true</append>
                  
                          <!-- DestFile is the file defined, where the `prepare-agent` will pe publishing the result of analysis,
                               for the defined `phase`. In our case is executed initially and to the `pre-integration-test` phase. -->
                          <destFile>${project.build.directory}/coverage-reports/jacoco_aggregation.exec</destFile>
                  
                          <!-- DataFile is the path from where the `report` goal will be reading the report
                               in order to create the `outputDirectory` .xml file. -->
                          <dataFile>${project.build.directory}/coverage-reports/jacoco_aggregation.exec</dataFile>
                  
                          <!-- To the goal `report`, will be reading the report from `dataFile` path and will be publishing the result,
                               to the `outputDirectory` path as an .xml file.
                               In our case, the report is generated for two times:
                                   - first time after the `test` phase
                                   - second time after the `post-integration-test` phase -->
                          <outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
                      </configuration>
                  
                      <executions>
                          <!-- Prepares the property pointing to the JaCoCo runtime agent which
                               is passed as VM argument when Maven the Surefire plugin is executed. -->
                          <execution>
                              <id>pre-unit-test</id>
                              <goals>
                                  <goal>prepare-agent</goal>
                              </goals>
                              <configuration>
                                  <!-- Sets the name of the property containing the settings for JaCoCo runtime agent. -->
                                  <propertyName>surefireArgLine</propertyName>
                              </configuration>
                          </execution>
                          
                          <!-- Ensures that the code coverage report `jacoco.xml` is generated once the unit tests were executed.
                               Executes the `report` goal after the `post-integration-test` phase. -->
                          <execution>
                              <id>post-unit-test</id>
                              <phase>test</phase>
                              <goals>
                                  <goal>report</goal>
                              </goals>
                          </execution>
                  
                          <!-- Prepares the property pointing to the JaCoCo runtime agent which
                               is passed as VM argument when Maven the Failsafe plugin is executed. -->
                          <execution>
                              <id>pre-integration-test</id>
                              <phase>pre-integration-test</phase>
                              <goals>
                                  <goal>prepare-agent</goal>
                              </goals>
                              <configuration>
                                  <!-- Sets the name of the property containing the settings for JaCoCo runtime agent. -->
                                  <propertyName>failsafeArgLine</propertyName>
                              </configuration>
                          </execution>
                          
                          <!-- Ensures that the code coverage report `jacoco.xml` is generated once the integration tests were executed.
                               Executes the `report` goal after the `post-integration-test` phase. -->
                          <execution>
                              <id>post-integration-test</id>
                              <phase>post-integration-test</phase>
                              <goals>
                                  <goal>report</goal>
                              </goals>
                          </execution>
                      </executions>
                  </plugin>
                  
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-surefire-plugin</artifactId>
                      <configuration>
                          <!-- Sets the VM argument line used when unit tests are run. -->
                          <argLine>${surefireArgLine}</argLine>
                      </configuration>
                  </plugin>
                  
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-failsafe-plugin</artifactId>
                      <configuration>
                          <!-- Sets the VM argument line used when integration tests are run. -->
                          <argLine>${failsafeArgLine}</argLine>
                      </configuration>
                  </plugin>
                  

                  生成报告后,您可以执行声纳命令来应用报告.

                  Once the reports are generated, you can execute the sonar commant to apply the reports.

                  mvn sonar:sonar -Dsonar.coverage.jacoco.xmlReportPaths="target/site/jacoco/jacoco.xml"
                  

                  这篇关于将 JaCoCo 与 SONAR 集成以实现单元和集成测试覆盖率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
                  <tfoot id='fqpiT'></tfoot>
                    <tbody id='fqpiT'></tbody>

                • <small id='fqpiT'></small><noframes id='fqpiT'>

                    <bdo id='fqpiT'></bdo><ul id='fqpiT'></ul>

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