空手道 0.9.1 未生成用于黄瓜报告的 cucumber.json
Karate 0.9.1 is not generating cucumber.json which is used for cucumber reports
将 空手道 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 文件?
从空手道 0.9.0 开始,支持的注释参数只有 features
和 tags
,没有其他参数。空手道是 not based on Cucumber any more.
并行运行器默认会生成您在 target/surefire-reports
中期望的 JSON。请仔细阅读文档的这一部分:https://github.com/intuit/karate#parallel-execution
因此您必须执行以下操作:
- 不要使用
@RunWith(Karate.class)
- 使用
@KarateOptions(features = "SampleFeature.feature")
- 使用
Runner.parallel()
- 不要将
maven-cucumber-reporting
用作 plugin
,而是将其用作 dependency
,请参考:https://github.com/intuit/karate/tree/master/karate-demo#example-report
- 编写(几行)代码以使用按上述 link
生成的 JSON
编辑 - 注意在 1.0 之后,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 文件?
从空手道 0.9.0 开始,支持的注释参数只有 features
和 tags
,没有其他参数。空手道是 not based on Cucumber any more.
并行运行器默认会生成您在 target/surefire-reports
中期望的 JSON。请仔细阅读文档的这一部分:https://github.com/intuit/karate#parallel-execution
因此您必须执行以下操作:
- 不要使用
@RunWith(Karate.class)
- 使用
@KarateOptions(features = "SampleFeature.feature")
- 使用
Runner.parallel()
- 不要将
maven-cucumber-reporting
用作plugin
,而是将其用作dependency
,请参考:https://github.com/intuit/karate/tree/master/karate-demo#example-report - 编写(几行)代码以使用按上述 link 生成的 JSON
编辑 - 注意在 1.0 之后,Cucumber JSON 默认不输出: