我有一个用于 spring-boot 应用程序的黄瓜集成测试套件,我正在尝试为其生成可视化报告,但我无法做到。
这是我的文件夹结构
|_ src
|_ main
|_ test
|_ java
|_ common
|_ steps
|_ CucumberIntegrationRunnerTest.java
|_ resources
|_ data
|_ [json files]
|_ [feature files]
|_ target
pom.xml 如下所示
<dependencies>
<!-- cucumber for integration tests-->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.18.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.18.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-spring</artifactId>
<version>7.18.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>5.8.1</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<version>7.18.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>5.8.1</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>optumcare-individual-azure-sink</projectName>
<outputDirectory>${project.build.directory}</outputDirectory>
<cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
<checkBuildResult>false</checkBuildResult>
<jsonFiles>
<param>**/cucumber.json</param>
</jsonFiles>
<buildNumber>1</buildNumber>
<checkBuildResult>false</checkBuildResult>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
我的测试运行器配置如下所示
@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("cucumber/integration")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "path_to_integration_folder")
@CucumberOptions(plugin = {"pretty", "json:target/cucumber.json"}, monochrome = true)
@CucumberContextConfiguration
@SpringBootTest
public class CucumberIntegrationRunnerTest { ... }
运行
mvn clean verify
顺利完成测试,并且正在生成报告 html,但我收到了 No JSON report file was found
错误。
我尝试了对 pom 或测试运行中的路径进行多次更改,但似乎没有任何效果。
不确定我在这里做错了什么...任何帮助将不胜感激。
要生成正确的 Cucumber 报告,您需要确保正确生成 JSON 报告,并且正确配置 Maven Cucumber 报告插件来读取它。 确保运行测试后在目标目录中创建 cucumber.json 文件。运行 mvn clean verify 后手动检查这一点。仔细检查路径是否与生成 JSON 文件的位置完全匹配。如果您仍然遇到问题,请检查 Maven 日志中是否有与插件执行或 JSON 文件生成相关的任何错误。