发布并回答我自己的问题,以防对其他人有所帮助。
将 Cluecumber 插件添加到您的 pom 文件中。在撰写本文时,最新版本是 2.3.4,但可以在此处检查更新。
<plugin>
<groupId>com.trivago.rta</groupId>
<artifactId>cluecumber-report-plugin</artifactId>
<version>2.3.4</version>
<executions>
<execution>
<id>report</id>
<phase>post-integration-test</phase>
<goals>
<goal>reporting</goal>
</goals>
</execution>
</executions>
<configuration>
<sourceJsonReportDirectory>${project.build.directory}/cucumber-report</sourceJsonReportDirectory>
<generatedHtmlReportDirectory>${project.build.directory}/generated-report
</generatedHtmlReportDirectory>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)添加json:target/cucumber-report/cucumber.json到您的Runner,因此您将拥有如下内容:
import io.cucumber.junit.CucumberOptions;
import io.cucumber.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(
features = {"."},
glue = {"my_folder.steps", "my_folder.hooks"},
monochrome = true,
plugin = {"json:target/cucumber-report/cucumber.json"}
)
public class MainRunner {
}
Run Code Online (Sandbox Code Playgroud)PS:不需要 html 目标
mvn cluecumber-report:reporting(原样)。这将生成一个仅在运行此命令时出现的文件夹。它将在target文件夹下并被称为generated-report. 在那里你应该找到index.html你的报告所在的文件(右键单击并在浏览器上打开它以查看它)。