Cucumber 报告在执行新功能文件时被覆盖

Cucumber reports getting overwritten when a new feature file is executed

我正在编写一个测试套件并且遇到了一个问题。我正在使用黄瓜并定义了多个功能文件。当我 运行 测试包时,一个功能文件的进度(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,然后您将获得 1 份报告。 由于每个RunWith代表一个套件,所以基本上只用1个套件得到1份报告。

有点晚了,但我承诺我会在这里发布解决方案。 Cucumber 有一个可用于生成报告的 Maven 插件。

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

plugin version is currently : 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>

要使用的配置:

黄瓜输出Path to where all the json reports are kept after the cucumber run 输出目录: Path to where the html report will be generated

就是这样,玩得开心。