Reputation: 113
Is there a way to change the output directory for the generated reports to an custom directory - in particular for the .json-Report files?
Documentation says (http://jgiven.org/userguide/ - 4.2):
[...] JGiven tries to autodetect when it is executed by the Maven surefire plugin [I'm using it] and in that case generates the reports into target/jgiven-reports/json. [...]
I'm using jGiven with Maven (for Appium Tests).
Configuration (pom.xml - dependencies):
<dependency>
<groupId>com.tngtech.jgiven</groupId>
<artifactId>jgiven-testng</artifactId>
<version>0.15.1</version>
<scope>test</scope>
</dependency>
Configuration (pom.xml - build/plugins):
<plugin>
<groupId>com.tngtech.jgiven</groupId>
<artifactId>jgiven-maven-plugin</artifactId>
<version>0.15.1</version>
<executions>
<execution>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
Since the directory is defined by jGiven it does not help to change the build-directory. It would still use the target/jgiven-reports/json
directory.
Thanks in advance!
Upvotes: 2
Views: 401
Reputation: 113
If somebody else is curious:
I found: String reportDirName = System.getProperty( JGIVEN_REPORT_DIR );
in https://github.com/TNG/JGiven/blob/fae0f3c8db0b00e7fa233cbd8f86306379def4b2/jgiven-core/src/main/java/com/tngtech/jgiven/impl/Config.java#L31 (current master).
Important part of it:
private static final String TRUE = "true";
private static final String FALSE = "false";
private static final String AUTO = "auto";
private static final String JGIVEN_REPORT_ENABLED = "jgiven.report.enabled";
public static final String JGIVEN_REPORT_DIR = "jgiven.report.dir";
private static final String JGIVEN_REPORT_TEXT = "jgiven.report.text";
private static final String JGIVEN_REPORT_TEXT_COLOR = "jgiven.report.text.color";
private static final String JGIVEN_FILTER_STACK_TRACE = "jgiven.report.filterStackTrace";
So you can either set your system properties via the maven-surefire-plugin in the pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<systemPropertyVariables>
<jgiven.report.dir>/my/custom/dir</jgiven.report.dir>
</systemPropertyVariables>
</configuration>
</plugin>
or just use Java's System.setProperty("jgiven.report.dir", "/my/custom/dir")
Upvotes: 3