首页 > 解决方案 > jacoco 在 IntelliJ 终端中报告

问题描述

我使用 Maven 插件生成 Jacoco 报告。我通过在 IntelliJ 终端中调用以下命令来做到这一点:

mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Dmaven.test.failure.ignore=true

乍一看,一切看起来都很好,但结果是错误的!jacoco.exec使用“普通”控制台(cmd、bash、powershell 等)时,生成的文件要大得多。IntelliJ 版本显示的代码覆盖率要小得多,这是不正确的。

为什么 IntelliJ 结果不同,为什么它是错误的?我在两种环境中从同一位置运行完全相同的命令。这是我的 Maven 设置的一部分:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
</plugin>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
</plugin>

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <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>
    <version>${jacoco-maven-plugin.version}</version>
</plugin>

有什么线索吗?

标签: javamavenintellij-ideajacocojacoco-maven-plugin

解决方案


推荐阅读