JGiven icon indicating copy to clipboard operation
JGiven copied to clipboard

Collect multiples JGiven JSON reports to a single HTML report.

Open zambrovski opened this issue 5 years ago • 4 comments

Imagine, I have a multi-module maven project with several modules containing their JGiven tests. Now in a CI I want to generate a single report out of them.

Currently, the Maven Plugin supports the sourceDirectory to read json files from one directory. It would be nice, if this would be either an ANT matcher or a list of directories could be specified.

zambrovski avatar Mar 05 '19 16:03 zambrovski

Currently, I'm using a workaround of copying all json files by the maven-resources-plugin to a single place and generate a report out of them...

zambrovski avatar Mar 05 '19 16:03 zambrovski

@zambrovski - the technique you describe works for me in several projects. I event went to far to zip the JSON reports and upload them as a secondary artifact to the artifact repository. In a different build I download reports from multiple projects, extract them and run the plugin.

ahus1 avatar Mar 19 '19 19:03 ahus1

Sounds like a useful extension. Could you make a concrete example of how you would expect this to look like in Maven? What would be the Maven-native way of doing this?

janschaefer avatar May 01 '19 11:05 janschaefer

I had the same problem with a multi-module Java 21 /Spring Boot 3 / Maven project. Here is the build section of my root pom for aggregating reports

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-jgiven-reports</id>
                        <phase>test</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>
                                ${project.parent.basedir}/target/jgiven-reports/
                            </outputDirectory>
                            <resources>
                                <resource>
                                    <directory>
                                        ${basedir}/target/jgiven-reports/
                                    </directory>
                                    <includes>
                                        <include>**/*.json</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.tngtech.jgiven</groupId>
                <artifactId>jgiven-maven-plugin</artifactId>
                <version>${jgiven.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <format>html</format>
                    <sourceDirectory>${project.parent.basedir}/target/jgiven-reports/</sourceDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>

serrafrank avatar Mar 11 '24 09:03 serrafrank