karate - 空手道 0.9.1 不生成用于黄瓜报告的 cucumber.json
问题描述
将空手道 0.6.1与黄瓜一起使用时。它正在代码中指定的路径中生成测试结果输出到cucumber.json文件。
然后使用 Masterthought 生成黄瓜报告。
@RunWith(Karate.class)
@CucumberOptions(monochrome = true, features = "SampleFeature.feature",
plugin = {"pretty", "html:target/site/cucumber-pretty",
"json:target/cucumber-html-reports/cucumber.json" })
但是当我们迁移到空手道 0.9.1以从 csv 文件中读取输入时。现在,它无法生成 cucumber.json,因此报告因 FileNotFoundException 而失败。
在 pom.xml 中附加 masterthought 的插件
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>3.15.0</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<!-- optional, per documentation set this to "true" to bypass
generation of Cucumber
Reports entirely, defaults to false if not specified -->
<skip>false</skip>
<!-- output
directory for the generated report -->
<outputDirectory>${project.build.directory}</outputDirectory>
<!-- optional, defaults to outputDirectory if not specified -->
<inputDirectory>${project.build.directory}/surefire-reports</inputDirectory>
<jsonFiles>
<!-- supports wildcard or name pattern -->
<param>target/cucumber-html-reports/cucumber-json-report.json</param>
</jsonFiles>
<cucumberOutput>${project.build.directory}/cucumber-html-reports/cucumber.json</cucumberOutput>
<!-- optional, defaults to outputDirectory if not specified -->
<classificationDirectory>${project.build.directory}/classifications</classificationDirectory>
<classificationFiles>
supports wildcard or name pattern
<param>sample.properties</param>
<param>other.properties</param>
</classificationFiles>
<parallelTesting>false</parallelTesting>
</configuration>
</execution>
</executions>
</plugin>
谁能建议从 0.6.1 到 0.9.1 的变化?
我应该怎么做才能生成 cucumber.json 文件?
解决方案
在 Karate 0.9.0 及更高版本中,注释上支持的唯一参数是features
and tags
,仅此而已。空手道不再以 Cucumber为基础。
target/surefire-reports
默认情况下,并行运行器将生成您期望的 JSON 。请仔细阅读文档的这一部分:https ://github.com/intuit/karate#parallel-execution
因此,您必须执行以下操作:
- 不要使用
@RunWith(Karate.class)
- 利用
@KarateOptions(features = "SampleFeature.feature")
- 使用
Runner.parallel()
- 不要将其
maven-cucumber-reporting
用作 aplugin
,而是将其用作 adependency
,请参阅:https ://github.com/intuit/karate/tree/master/karate-demo#example-report - 编写(几行)代码以使用上述链接中所述生成的 JSON
编辑 - 请注意,从 1.0 开始,默认情况下不输出 Cucumber JSON:https ://stackoverflow.com/a/66682940/143475
推荐阅读
- reactjs - 从与活动存储导轨 api 反应的图像上传
- reactjs - 需要将复选框更改为 Radio -React js
- python - 重排后的Printing_Alice的图书馆
- python - Locust 在暂时收到错误 500 后停止
- angularjs - 如何从凉亭组件转移到节点模块
- python - 在模型编译之前/之后使用“conv_base.trainable = False”的模型差异
- bison - 在函数“yyparse”中:y.tab.c:未定义对“ex”的引用
- java - 必要时折叠对象列表的最佳解决方案
- java - 在多个 jar 中外部化类
- python - 使用 mplcursors.cursor().connect() 显示栏名称