Maven Cucumber 报告多个 JSON 文件

我的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>

这将生成一个报告,但仅使用最后一个功能。我有多个跑步者,所以我试图弄清楚:


一个。如何将多个 JSON 合并到一个报表中,或者


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


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


慕桂英4014372
浏览 165回答 2
2回答

慕的地10843

如果您可以运行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

德玛西亚99

问题是正在使用的版本(即2.8)不支持多个JSON文件。解决方案是:&nbsp;<plugin>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <groupId>net.masterthought</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <artifactId>maven-cucumber-reporting</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <version>4.5.0</version>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <executions>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <id>execution</id>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <phase>verify</phase>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <goals>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <goal>generate</goal>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </goals>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <projectName>ExecuteAutomation</projectName>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <inputDirectory>${project.build.directory}/jsonReports</inputDirectory>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <outputDirectory>${project.build.directory}/cucumber-report-html</outputDirectory>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <jsonFiles>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <!-- supports wildcard or name pattern -->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <param>**/*.json</param>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </jsonFiles>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </executions>&nbsp; &nbsp; &nbsp; &nbsp; </plugin>在 https://github.com/damianszczepanik/maven-cucumber-reporting 阅读更多内容
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java