【发布时间】:2015-12-18 17:20:09
【问题描述】:
我已按照说明在此处为我们的声纳项目启用单元和集成测试: http://docs.sonarqube.org/display/PLUG/Code+Coverage+by+Integration+Tests+for+Java+Project
我的 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>
报告的单元测试很好,但集成测试没有。在 Bamboo 日志中,我可以看到声纳正在所有子模块中寻找集成测试和单元测试,但是当它到达父模块时,它从不运行 JaCoCoSensor 或 JaCoCoItSensor。这两个传感器都针对每个模块项目运行。我还注意到每个模块项目都有一个 JaCoCoOverallSensor 运行,但不是父项目。
如何让 JaCoCoItSensor 为父项目运行?
【问题讨论】:
-
父项目是否包含java文件?
-
@benzonico 父级不包含任何 java 文件。但github.com/SonarSource/sonar-examples/tree/master/projects/… 的 Sonar 示例也没有
标签: sonarqube jacoco sonarqube5.2