2015-12-18 73 views
1

我遵循了启用单元测试和集成测试我们的声纳项目在这里说明的父POM目标目录: http://docs.sonarqube.org/display/PLUG/Code+Coverage+by+Integration+Tests+for+Java+ProjectSonarQube不读书集成JaCoCo测试覆盖在一个多模块项目

我的POM的设置几乎是相同的在这个例子中的设置: https://github.com/SonarSource/sonar-examples/tree/master/projects/languages/java/code-coverage/combined%20ut-it/combined-ut-it-multimodule-maven-jacoco

父POM设置:

 <profile> 
     <id>code-coverage</id> 
     <build> 
      <plugins> 
       <plugin> 
        <groupId>org.jacoco</groupId> 
        <artifactId>jacoco-maven-plugin</artifactId> 
        <version>${jacoco.version}</version> 
        <configuration> 
         <append>true</append> 
        </configuration> 
        <executions> 
         <execution> 
          <id>default-prepare-agent</id> 
          <goals> 
           <goal>prepare-agent</goal> 
          </goals> 
         </execution> 
         <execution> 
          <id>default-agent-for-it</id> 
          <goals> 
           <goal>prepare-agent-integration</goal> 
          </goals> 
         </execution> 
         <execution> 
          <id>default-report</id> 
          <phase>verify</phase> 
          <goals> 
           <goal>report</goal> 
          </goals> 
          <configuration> 
           <excludes> 
            <exclude>static/**/*.jar</exclude> 
            <exclude>static/**/*.class</exclude> 
           </excludes> 
          </configuration> 
          </execution> 
        </executions> 
       </plugin> 
      </plugins> 
     </build> 
    </profile> 

我们有一个具体的模件Ë将运行集成测试:

 <profile> 
     <id>code-coverage</id> 
     <build> 
      <plugins> 
       <plugin> 
        <groupId>org.jacoco</groupId> 
        <artifactId>jacoco-maven-plugin</artifactId> 
        <version>${jacoco.version}</version> 
        <configuration> 
         <!-- The destination file for the code coverage report has to be set to the same value 
          in the parent pom and in each module pom. Then JaCoCo will add up information in 
          the same report, so that, it will give the cross-module code coverage. --> 
         <destFile>${project.basedir}/../target/jacoco-it.exec</destFile> 
        </configuration> 
       </plugin> 
      </plugins> 
     </build> 
    </profile> 

我已经配置声纳寻找UT和IT: enter image description here

单元测试均有报告很好,但没有集成测试。在Bamboo日志中,我可以看到声呐正在寻找所有子模块中的集成测试和单元测试,但是当它到达父模块时,它永远不会运行JaCoCoSensor或JaCoCoItSensor。这两个传感器都针对每个模块项目运行。我还注意到JaCoCoOverallSensor为每个模块项目运行,但不是父项目。

如何让JaCoCoItSensor运行父项目?

+0

是否父项目中包含的Java文件? – benzonico

+0

@benzonico父母不包含任何Java文件。但是,在https://github.com/SonarSource/sonar-examples/tree/master/projects/languages/java/code-coverage/combined%20ut-it/combined-ut-it-multimodule-maven上的声纳示例-jacoco –

回答

1

我添加了一些配置属性,它开始工作。

父pom.xml中添加:

<properties> 
    ... 
    <sonar.jacoco.itReportPath>${project.basedir}/../target/jacoco-it.exec</sonar.jacoco.itReportPath> 
    <sonar.language>java</sonar.language> 
</properties> 

IT测试模块,我改变了:

<destFile>${sonar.jacoco.itReportPath}/../target/jacoco-it.exec</destFile> 

要这样:

<destFile>${sonar.jacoco.itReportPath}</destFile> 
相关问题