0
votes

I'm trying to generate aggregate surefire report using maven-surefire-report-plugin.But the issue is that the report contain previous execution results only. It's mean if I execute the test for Nth time it will display (N-1)th time execution results.When I clean all target from mvn 'clean install' command the execution results will be 0.

Aggregate Surefire report refer the generated TEST-.xml files under ${basedir}/target/surefire-reports to create the report. Currently TEST-TestSuite.xml file is generated under each module. So setting up the aggregate parameter value as true and it's generate aggregate report by referring these Test-.xml file in each module .

Project test design with separate module as below.

├── 1.Scenario
|   ├── 1.1 Sub- scenario
|   |   ├── 1.1.1-test -scenario
|   |   |   ├── src/test
|   |   |   |  ├── pom.xml
|   |   |   |  ├── target
|   |   |   |  |  ├──Surefire reports
|   |   |   |  |  | ├──TEST-*.xml
|   |   |   |  |  | |
├── target
├── aggregate report (surefire.html)
├── pom.xml (parent)

maven-surefire-plugin has configure inside the module pom and a Test-.xml will create for each module separately. maven-surefire-report-plugin has configure at the parent pom and suppose to generate aggregate report for all module by referring Test-.xml in each module.

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-surefire-report-plugin</artifactId>
   <version>2.4.2</version>
   <inherited>true</inherited>
   <configuration>
      <aggregate>true</aggregate>
      <outputDirectory>${basedir}/target/aggregate-surefire-report</outputDirectory>
   </configuration>
   <executions>
      <execution>
         <phase>install</phase>
         <goals>
            <goal>report</goal>
         </goals>
      </execution>
   </executions>
</plugin>

Expected result is the aggregate report of the current execution but actual result gives the previous execution result.

Anyone know why this issue occurs?

1

1 Answers

-1
votes

Solution I found was to execute the maven goals separately. I mean "mvn clean test" and then "mvn surefire-report:report-only" this generates reports of the run we intended.