[
https://issues.apache.org/jira/browse/SUREFIRE-2004?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17515832#comment-17515832
]
James Z.M. Gao commented on SUREFIRE-2004:
------------------------------------------
save the following script as gen-bug.sh, the you can compare the two command
result:
- ./gen-bug.sh # ok, output 100%
- ./gen-bug.sh -Daggregate # error, cannot find 100%
{code:bash}
#!/bin/sh
set -e
bug=$(mktemp -d)
trap 'rm -rf "$bug"' EXIT
mkdir -p "$bug/src/main/java" "$bug/src/test/java"
>"$bug"/src/main/java/A.java echo 'class A {}'
>"$bug"/src/test/java/ATest.java echo 'public class ATest { @org.junit.Test
>public void testFuncA() { org.junit.Assert.assertTrue(null != new A()); } }'
>"$bug"/pom.xml cat <<'END'
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.11.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
<phase>post-site</phase>
<configuration>
<executable>grep</executable>
<arguments>
<argument>100%</argument>
<argument>${project.reporting.outputDirectory}/surefire-report.html</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.0.0-M5</version>
<reportSets>
<reportSet>
<reports>
<report>report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
</project>
END
mvn -q -f "$bug/pom.xml" post-site "$@"
{code}
> Empty report for single-module project with 'aggregate=true'
> ------------------------------------------------------------
>
> Key: SUREFIRE-2004
> URL: https://issues.apache.org/jira/browse/SUREFIRE-2004
> Project: Maven Surefire
> Issue Type: Bug
> Components: Maven Surefire Report Plugin
> Affects Versions: 2.4, 3.0.0-M5
> Reporter: Alexander Kriegisch
> Priority: Major
>
> Using either {{-Daggregate=true}} on CLI or {{<aggregate>true</aggregate>}}
> in the plugin configuration leads to an empty report (i.e. zero tests
> reported) when e.g. executing
> {code:none}
> mvn -Dmaven.test.failure.ignore=true -Daggregate=true clean verify
> surefire-report:report-only
> {code}
> in the context of a single-module project. As soon as I make the root module
> pom-packaged and move the tests to into a child module, the aggregate report
> works.
> FYI, if I do not define the plugin and its version in my POM at all, the
> default version 2.4 used by Maven on my workstation has the same problem, so
> this does not seem to be a 3.0.0-M5 issue only.
> ----
> Background info about how and why I actually stumbled across this problem: I
> have an OSS multi-module project with lots of expensive UI tests. The full
> build can take 2.5 hours. I wanted to test a few CLI settings before creating
> an additional GitHub CI build workflow which can be run on demand and always
> runs all tests in all modules (ignoring errors and failures), no matter what.
> In the end, it is supposed to create a single-file aggregate HTML report
> which can easily be attached to the build and later is available for
> download, if the user so chooses in order to analyse failing tests
> comfortable and without having to scroll through build logs. You get the
> picture, I guess. In the original project, there is a pom-packaged root POM,
> so the problem described in this issue does not occur there. I simply created
> a single-module dummy project in order to verify the effect of certain build
> options quickly and not having to wait for the slow original build to finish.
> Eventually, I noticed the issue described above.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)