首页 > 解决方案 > 空手道 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 文件?

标签: karatecucumber-java

解决方案


在 Karate 0.9.0 及更高版本中,注释上支持的唯一参数是featuresand tags,仅此而已。空手道不再以 Cucumber为基础。

target/surefire-reports默认情况下,并行运行器将生成您期望的 JSON 。请仔细阅读文档的这一部分:https ://github.com/intuit/karate#parallel-execution

因此,您必须执行以下操作:

编辑 - 请注意,从 1.0 开始,默认情况下不输出 Cucumber JSON:https ://stackoverflow.com/a/66682940/143475


推荐阅读