junit - 执行新功能文件时,Cucumber 报告被覆盖

标签 junit cucumber maven-surefire-plugin cucumber-junit cucumber-java

我正在编写一个测试套件,但遇到了一个问题。我正在使用 cucumber 并定义了多个功能文件。当我运行测试包时,下一个功能文件执行开始时,一个功能文件的进度(html 报告和 json 格式)会被覆盖。

我定义了多个运行这些功能文件的测试类。我正在尝试找到一种方法,可以获得所有功能运行的单个 html 报告,以提供综合 View 。

引用示例测试文件:

@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 {

}

让我们知道如何才能获得综合报告。

最佳答案

有点晚了,但正如 promise 的那样,我在这里发布了解决方案。 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格式绑定(bind)多个测试报告。

示例实现如下:

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

要使用的配置:

cucumberOutput:cucumber 运行后保存所有 json 报告的路径 outputDirectory:生成 html 报告的路径

就这样,祝你玩得开心。

关于junit - 执行新功能文件时,Cucumber 报告被覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41423710/

相关文章:

testing - JUnit - 在 tearDown() 中访问失败消息

junit - JUnit 3 和 JUnit 4 之间的区别

ios - 为 iOS 设置 Frank 时出现问题

ruby-on-rails - Cucumber 将 pdf 读入临时文件

java - SpringJUnit4ClassRunner 在 Spring5 中损坏了吗?

maven - JUnit:默认选择性地不运行一些测试用例

java - 如何在intellij中通过jruby运行cuke4duke

azure-devops - 图片未出现在 Jacoco 覆盖率报告中(既不在 Index.html 中也不在 VSTS 中)

java - Maven Surefire 插件 + 并行构建

java - 在 pom.xml 中配置 Maven 插件两次