JGiven
JGiven copied to clipboard
Collect multiples JGiven JSON reports to a single HTML report.
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.
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 - 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.
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?
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>