0

我的 POM 目前看起来像,

<groupId>net.masterthought</groupId>
            <artifactId>maven-cucumber-reporting</artifactId>
            <version>2.8.0</version>
            <executions>
                <execution>
                    <id>execution</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <projectName>ExecuteAutomation</projectName>
                        <outputDirectory>${project.build.directory}/cucumber-report-html</outputDirectory>
                        <cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
                    </configuration>
                </execution>
            </executions>
        </plugin>

这确实会生成报告,但仅包含最后一个功能。我有多个跑步者,所以我试图弄清楚:

A. 如何将多个 JSON 合并到一份报告中或

B. 如何在每个测试完成时附加到一个 JSON 文件?

这些中的任何一个似乎都是一个可行的解决方案,尽管我更喜欢 A 因为我似乎只在我的 pom.xml 中丢失了一行,因为我目前已经在生成多个 JSON 文件

4

2 回答 2

1

问题是正在使用的版本(即 2.8)不支持多个 JSON 文件。

解决方案是:

 <plugin>
            <groupId>net.masterthought</groupId>
            <artifactId>maven-cucumber-reporting</artifactId>
            <version>4.5.0</version>
            <executions>
                <execution>
                    <id>execution</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <projectName>ExecuteAutomation</projectName>
                        <inputDirectory>${project.build.directory}/jsonReports</inputDirectory>
                        <outputDirectory>${project.build.directory}/cucumber-report-html</outputDirectory>
                        <jsonFiles>
                            <!-- supports wildcard or name pattern -->
                            <param>**/*.json</param>
                        </jsonFiles>
                    </configuration>
                </execution>
            </executions>
        </plugin>

阅读更多https://github.com/damianszczepanik/maven-cucumber-reporting

于 2019-03-11T15:14:22.897 回答
1

如果您可以运行 bash 命令并且机器上可能有jq可用,则可以尝试在具有不同名称的文件中生成报告,然后使用 jq 将它们合并回一个文件

尽管我不并行运行并且不依赖任何插件,但我做类似的事情,我使用surefire插件运行

免责声明:我没有使用 --format 测试报告名称覆盖,因此该部分可能对您有所不同,但想法是相同的

mvn test -Dcucumber.options="--format=json:target/cucumber_test1.json"
mvn test -Dcucumber.options="--format=json:target/cucumber_test2.json"
...

jq -s '[.[][]]' target/cucumber_*.json > target/cucumber.json

于 2020-03-18T17:53:29.390 回答