Search code examples
javamavencucumbercucumber-jvm

Maven Cucumber Reporting Multiple JSON files


My POM currently looks like,

<groupId>net.masterthought</groupId>
            <artifactId>maven-cucumber-reporting</artifactId>
            <version>2.8.0</version>
            <executions>
                <execution>
                    <id>execution</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <projectName>ExecuteAutomation</projectName>
                        <outputDirectory>${project.build.directory}/cucumber-report-html</outputDirectory>
                        <cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
                    </configuration>
                </execution>
            </executions>
        </plugin>

This does generate a report but only with the last feature. I have multiple runners, so I'm trying to figure out either:

A. How do I combine multiple JSON into one report or

B. How do I append on to one JSON file as each test finishes?

Either of these seems like a viable solution, Although I would prefer A because it seems like I'm only missing one line in my pom.xml to do so as I currently am already generating multiple JSON files


Solution

  • The problem is that the version being used (i.e. 2.8) doesn't support multiple JSON files.

    The solution is:

     <plugin>
                <groupId>net.masterthought</groupId>
                <artifactId>maven-cucumber-reporting</artifactId>
                <version>4.5.0</version>
                <executions>
                    <execution>
                        <id>execution</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <projectName>ExecuteAutomation</projectName>
                            <inputDirectory>${project.build.directory}/jsonReports</inputDirectory>
                            <outputDirectory>${project.build.directory}/cucumber-report-html</outputDirectory>
                            <jsonFiles>
                                <!-- supports wildcard or name pattern -->
                                <param>**/*.json</param>
                            </jsonFiles>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
    

    Read more at https://github.com/damianszczepanik/maven-cucumber-reporting