j给定输出目录

jGiven Output Directory

有没有办法将生成的报告的输出目录更改为自定义目录 - 特别是 .json-报告文件?

文档说 (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. [...]

我将 jGiven 与 Maven 一起使用(用于 Appium 测试)。

配置(pom.xml - 依赖项):

<dependency>
        <groupId>com.tngtech.jgiven</groupId>
        <artifactId>jgiven-testng</artifactId>
        <version>0.15.1</version>
        <scope>test</scope>
</dependency>

配置(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>

由于目录是由 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";

因此您可以通过 pom.xml:

中的 maven-surefire-plugin 设置您的系统属性
<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")