我正在编写测试套件并遇到了一个问题。我正在使用黄瓜并定义了多个功能文件。当我运行测试包时,一个功能文件的进度(html报告和json格式)在下一个功能文件执行开始时被覆盖。
我定义了多个运行这些功能文件的测试类。我试图找到一种方法,我可以获得所有功能运行的单个html报告,以提供统一视图。
ref:
的示例测试文件@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 {
}
让我们知道如何制作合并报告。
答案 0 :(得分: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>
要使用的配置:
cucumberOutput :Path to where all the json reports are kept after the cucumber run
outputDirectory :Path to where the html report will be generated
这就是它,玩得开心。
答案 1 :(得分:1)
就像我在上面的评论中所说,将您的套件合并为1,然后您将获得1个报告。
由于每个RunWith
表示一个套件,因此基本上只使用一个套件来获得1个报告。