You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

pitest-maven插件report-aggregate目标多模块项目配置求助

Hey there! I’ve dealt with this exact pitfall when trying to get aggregated mutation reports from a multi-module Maven project with pitest, so I know how frustrating it can be. Let me share the configuration that finally worked for me, step by step.

Key Configuration in the Parent POM

The trick lies in enabling aggregation mode in the parent project’s pom.xml and setting up the plugin correctly so it pulls results from all child modules. Here’s a complete, working snippet you can adapt:

<build>
  <plugins>
    <plugin>
      <groupId>org.pitest</groupId>
      <artifactId>pitest-maven</artifactId>
      <version>1.15.0</version> <!-- Use the latest stable version here -->
      <executions>
        <execution>
          <id>run-pitest-aggregate</id>
          <phase>verify</phase>
          <goals>
            <goal>mutationCoverage</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <!-- This is the critical flag for aggregation -->
        <aggregate>true</aggregate>
        <!-- Target all classes across your modules (adjust to your package structure) -->
        <targetClasses>
          <param>com.yourorg.*</param>
        </targetClasses>
        <!-- Target all test classes (adjust if your tests follow a different naming pattern) -->
        <targetTests>
          <param>com.yourorg.*Test</param>
        </targetTests>
        <!-- Add JUnit 5 support if you're using it (skip if you use JUnit 4) -->
        <plugins>
          <plugin>
            <groupId>org.pitest</groupId>
            <artifactId>pitest-junit5-plugin</artifactId>
            <version>1.2.1</version> <!-- Match version compatible with your pitest core -->
          </plugin>
        </plugins>
      </configuration>
    </plugin>
  </plugins>
</build>
Child Module Setup

Most of the time, you don’t need any special configuration in child modules—they’ll inherit the parent’s pitest settings automatically.

If you have a child module that you want to exclude from mutation testing (like a pure API module with no tests), just add this to its pom.xml:

<build>
  <plugins>
    <plugin>
      <groupId>org.pitest</groupId>
      <artifactId>pitest-maven</artifactId>
      <configuration>
        <skip>true</skip>
      </configuration>
    </plugin>
  </plugins>
</build>
Generating the Aggregated Report

Run this command from the root of your parent project:

mvn verify

Or if you want to run pitest directly without the full verify phase:

mvn pitest:mutationCoverage

The aggregated report will be generated in [parent-project-root]/target/pit-reports—just open the index.html file in your browser to view the combined results from all child modules.

Troubleshooting Tips
  • Empty report? Double-check your targetClasses parameter—make sure it matches the package structure of all your child modules.
  • Tests failing in pitest but passing normally? Ensure your test classes don’t have any module-specific dependencies that pitest isn’t picking up (like missing test resources).
  • Version conflicts? Always make sure the pitest core version and any plugins (like JUnit 5) are compatible—check the pitest docs for version mappings.

内容的提问来源于stack exchange,提问作者Fernando Barbeiro

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:25:09