【问题标题】:SonarQube not reading Integration JaCoCo Test coverage in parent pom target directory of a multi-module projectSonarQube 未在多模块项目的父 pom 目标目录中读取集成 JaCoCo 测试覆盖率
【发布时间】: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>

我已将 Sonar 配置为查找 UT 和 IT:

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

如何让 JaCoCoItSensor 为父项目运行?

【问题讨论】:

标签: sonarqube jacoco sonarqube5.2


【解决方案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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-15
    • 2013-07-05
    • 2017-01-10
    • 1970-01-01
    • 2014-10-25
    • 1970-01-01
    • 2014-10-03
    • 1970-01-01
    相关资源
    最近更新 更多