我遵循了啓用單元測試和集成測試我們的聲納項目在這裏說明的父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>
單元測試均有報告很好,但沒有集成測試。在Bamboo日誌中,我可以看到聲吶正在尋找所有子模塊中的集成測試和單元測試,但是當它到達父模塊時,它永遠不會運行JaCoCoSensor或JaCoCoItSensor。這兩個傳感器都針對每個模塊項目運行。我還注意到JaCoCoOverallSensor爲每個模塊項目運行,但不是父項目。
如何讓JaCoCoItSensor運行父項目?
是否父項目中包含的Java文件? – benzonico
@benzonico父母不包含任何Java文件。但是,在https://github.com/SonarSource/sonar-examples/tree/master/projects/languages/java/code-coverage/combined%20ut-it/combined-ut-it-multimodule-maven上的聲納示例-jacoco –