2017-09-21 78 views
1

有沒有辦法將生成的報告的輸出目錄更改爲自定義目錄 - 特別是.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目錄。

在此先感謝!

回答

1

如果別人是好奇:

我發現: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")