2

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

文档说(http://jgiven.org/userguide/ - 4.2):

[...] JGiven 尝试自动检测它何时由 Maven surefire 插件 [我正在使用它] 执行,并在这种情况下将报告生成到 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 - 构建/插件):

<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目录。

提前致谢!

4

1 回答 1

3

如果有人好奇:

我发现: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")

于 2017-09-22T09:27:19.667 回答