jGiven输出目录
问题描述:
有没有办法将生成的报告的输出目录更改为自定义目录 - 特别是.json-Report文件?jGiven输出目录
文件说,(http://jgiven.org/userguide/ - 4.2):
[...] JGiven尝试当它被Maven的万无一失插件[我用它]在这种情况下,执行自动检测生成报告进入target/jgiven-reports/json。 [...]
我使用jGiven与Maven(for Appium测试)。
配置(pom.xml中 - 依赖):
<dependency>
<groupId>com.tngtech.jgiven</groupId>
<artifactId>jgiven-testng</artifactId>
<version>0.15.1</version>
<scope>test</scope>
</dependency>
配置(pom.xml中 - 建立/插件):
<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>
由于目录由jGiven定义它无助于更改构建目录。它仍然会使用target/jgiven-reports/json
目录。
在此先感谢!
答
如果别人是好奇:
我发现:String reportDirName = System.getProperty(JGIVEN_REPORT_DIR);
在https://github.com/TNG/JGiven/blob/fae0f3c8db0b00e7fa233cbd8f86306379def4b2/jgiven-core/src/main/java/com/tngtech/jgiven/impl/Config.java#L31(当前主)。
重要组成部分:
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";
所以,你可以通过Maven的万无一失,插件在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>
或只使用Java的System.setProperty("jgiven.report.dir", "/my/custom/dir")