Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Maven Cucumber报告多个JSON文件_Java_Maven_Cucumber_Cucumber Jvm - Fatal编程技术网

Java Maven Cucumber报告多个JSON文件

Java Maven Cucumber报告多个JSON文件,java,maven,cucumber,cucumber-jvm,Java,Maven,Cucumber,Cucumber Jvm,我的POM现在看起来像 <groupId>net.masterthought</groupId> <artifactId>maven-cucumber-reporting</artifactId> <version>2.8.0</version> <executions> <execution>

我的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>
net.masterthink
马文黄瓜报道
2.8.0
执行
验证
生成
执行自动化
${project.build.directory}/html报告
${project.build.directory}/cucumber.json
这将生成一个报告,但仅使用最后一个功能。我有多个跑步者,所以我试图找出:

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

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


这两种方法似乎都是可行的解决方案,但我更喜欢一种,因为我的pom.xml中似乎只缺少一行,因为我目前已经生成了多个JSON文件。问题是所使用的版本(即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>

网络智囊团

问题在于所使用的版本(即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>

网络智囊团

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


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