gpt4 book ai didi

java - j给定输出目录

转载 作者:行者123 更新时间:2023-11-30 07:51:57 24 4
gpt4 key购买 nike

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

文档说(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 - 构建/插件):

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

提前致谢!

最佳答案

如果有人好奇:

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

关于java - j给定输出目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46345385/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com