【问题标题】:Make Integraton Test cover all submodules使集成测试覆盖所有子模块
【发布时间】:2017-08-19 21:17:56
【问题描述】:

我确实搜索过类似的主题。但我的问题不同。 背景是我有一个单一的spring boot项目,并且它变得越来越大。然后我按照 springSpring boot - Creating a Multi Module Project 的指南将其拆分为多个模块。

假设,现在我有 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>

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

【问题讨论】:

标签: maven spring-boot sonarqube multi-module jacoco-maven-plugin


【解决方案1】:

你可以在你的目标标签之后添加 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>

这会将每个模块中的所有结果聚合到一个文件中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-08
    • 1970-01-01
    • 2016-06-15
    • 2013-10-14
    • 2017-11-22
    • 2019-08-12
    • 1970-01-01
    相关资源
    最近更新 更多