4

我正在編寫測試套件並遇到問題。我正在使用黃瓜並定義了多個功能文件。當我運行測試包時,一個功能文件的進度(html報告和json格式)在下一個功能文件執行開始時被覆蓋。執行新功能文件時會覆蓋黃瓜報告

我有多個測試類定義運行這些功能文件。我正試圖找到一種方法,可以爲所有功能運行獲取單個HTML報告以提供統一視圖。

爲參考樣本測試文件:

@CucumberOptions(plugin = { "pretty", "html:target/report/html", 
"json:target/report/json/result.json" }) 
public class BaseFeature { 

} 

@RunWith(Cucumber.class) 
@CucumberOptions(features = "classpath:test/feature/rest/query.feature" 
, monochrome = true 
, glue={"a.b.c.rest"}) 
public class RunTest1 extends BaseFeature { 

} 

@RunWith(Cucumber.class) 
@CucumberOptions(features="classpath:test/feature/soap/book.feature" 
, monochrome = true 
, glue="a.b.c.soap") 
public class RunTest2 extends BaseFeature { 

} 

讓知道什麼可以做有一個綜合報告。

+1

所有的課程都是套房,對嗎?所以一次只能爲一個套件生成報告。 –

+0

將所有內容合併到一個套件中,並獲得中央報告。 –

+0

是的,因爲每個RunWith都意味着獨立的套件。因此,一次只能使用1名運動員來生成報告。 請在下面提供您的答案,以幫助未來面臨同樣問題的其他人。 –

回答

3

稍遲,但作爲承諾我在這裏發佈解決方案。 Cucumber有一個可用於生成報告的maven插件。目前

<groupId>net.masterthought</groupId> 
<artifactId>maven-cucumber-reporting</artifactId> 
<version>${maven-cucumber-reporting.version}</version> 

插件版本:3.3.0

這個插件提供了一些有用的配置參數,它允許你綁定在JSON格式多個測試報告。

實現示例如下:

<plugins> ... 

    <plugin> 
    <groupId>net.masterthought</groupId> 
    <artifactId>maven-cucumber-reporting</artifactId> 
    <version>${maven-cucumber-reporting.version}</version> 
    <executions> 
     <execution> 
     <id>execution</id> 
     <phase>verify</phase> 
     <goals> 
      <goal>generate</goal> 
     </goals> 
     <configuration> 
      <projectName>test-report</projectName> 
      <outputDirectory>${project.build.directory}/bdd/report</outputDirectory> 
      <cucumberOutput>${project.build.directory}/report/json</cucumberOutput> 
      <parallelTesting>false</parallelTesting> 
     </configuration> 
     </execution> 
    </executions> 
    </plugin> 

</plugins> 

配置中使用:

cucumberOutputPath to where all the json reports are kept after the cucumber run 輸出目錄Path to where the html report will be generated

這就是它帶來的無限樂趣。

1

就像我在上面的評論中所說的,將你的套件合併到1中,那麼你將得到1個報告。 由於每個RunWith表示一個套件,所以基本上只使用1個套件來獲得1個報告。

+1

我同意關於套件的聲明。但不同意這是獲得中央報告的唯一途徑,我將在今天更新這個答案。 –

+0

已添加完成答案。 –