jGiven输出目录

时间:2017-09-21 13:33:09

标签: java maven appium jgiven

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

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

  

[...] JGiven尝试在Maven surefire插件[我正在使用它]执行时自动检测,并在这种情况下生成报告到target / jgiven-reports / json。 [...]

我正在使用带有Maven的jGiven(用于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定义的,因此无法更改build-directory。它仍然会使用target/jgiven-reports/json目录。

提前致谢!

1 个答案:

答案 0 :(得分:3)

如果有人好奇的话:

我在https://github.com/TNG/JGiven/blob/fae0f3c8db0b00e7fa233cbd8f86306379def4b2/jgiven-core/src/main/java/com/tngtech/jgiven/impl/Config.java#L31(当前主人)中找到了String reportDirName = System.getProperty( JGIVEN_REPORT_DIR );

重要部分:

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")