2

I have a simple Maven project configured to generate a JUnit report with the Surefire plugin, and a coverage report with Jacoco.

After running mvn test, I expect to find:

  1. jacoco report files in reports/jacoco
  2. surefire-report.html in reports/junit

However for some reason the Jacoco report files appear in both the reports/jacoco AND reports/junit folder:

enter image description here

Please help me to understand and correct.

pom.xml:

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${surefire.plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>${surefire.plugin.version}</version>
                <configuration>
                    <outputDirectory>${basedir}/reports/junit</outputDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>during-tests</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.plugin.version}</version>
                <executions>
                    <execution>
                        <id>default-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-check</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <rule>
                                    <element>BUNDLE</element>
                                    <limits>
                                        <limit>
                                            <counter>INSTRUCTION</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.80</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                            </rules>
                        </configuration>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/reports/jacoco</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            ...
Phil
  • 598
  • 1
  • 9
  • 21
  • 2
    I strongly recommend to remove the configuration for outputDirectory (leave the defaults).. – khmarbaise Jan 26 '22 at 07:45
  • Agreed, changing the output directory has undesirable side-effects. Reverting to the default, the target/site directory is clean and sufficient. Report files can be copied elsewhere in a separate step. – Phil Jan 27 '22 at 02:25

0 Answers0