-1

我也搜索过类似主题。但我的问题是不同的。 背景是我有一个单一的弹簧启动项目,它变得越来越大。然后按照弹簧Spring boot - Creating a Multi Module Project的指导将它分成多个模块。Make Integraton Test覆盖所有子模块

比方说,现在我有2个项目:Web和ServiceLayer。我之前的所有集成测试都在Web上,看起来像是声纳,我只能看到proejct-web的覆盖范围。

我使用jacoco Maven插件,这里是maven的POM:

<plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-report-plugin</artifactId> 
      <version>2.19.1</version> 
      <configuration> 
       <showSuccess>false</showSuccess> 
      </configuration> 
     </plugin> 

     <!-- JaCoCo configuration --> 
     <plugin> 
      <groupId>org.jacoco</groupId> 
      <artifactId>jacoco-maven-plugin</artifactId> 
      <version>0.7.5.201505241946</version> 
      <executions> 
       <execution> 
        <id>default-prepare-agent</id> 
        <goals> 
         <goal>prepare-agent</goal> 
        </goals> 
       </execution> 
       <execution> 
        <id>default-report</id> 
        <phase>prepare-package</phase> 
        <goals> 
         <goal>report</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

如何配置,使声纳可用的子模块的覆盖范围? 谢谢!

+0

[如何配置多模块Maven + Sonar + JaCoCo提供合并覆盖率报告?](http://stackoverflow.com/questions/13031219/how-to-configure-multi-module-maven-声纳jacoco到放弃的合并覆盖-REP) – philip

回答

0

您可以将目标标记后添加destFile标签

像这样的事情

<plugin> 
    <groupId>org.jacoco</groupId> 
    <artifactId>jacoco-maven-plugin</artifactId> 
    <version>0.7.8</version> 
    <configuration> 
     <append>true</append> 
    </configuration> 
    <executions> 
     <execution> 
      <id>default-prepare-agent</id> 
      <goals> 
       <goal>prepare-agent</goal> 
      </goals> 
      <configuration> 
       <destFile>${project.basedir}/../target/jacoco.exec</destFile> 
      </configuration> 
     </execution> 
     <execution> 
      <id>default-report</id> 
      <phase>prepare-package</phase> 
      <goals> 
       <goal>report</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin> 

这会都汇集在每个模块的所有结果到一个文件中。