我估计这是 Cucumber 插件和 Cucumber 旧版本的版本兼容 Bug,不知道官方什么时候做兼容性修复,我所用的版本是6.8.1。
最近在写一个 Spring Boot 做 BDD 的例子,在用 IntelliJ IDEA 中安装了 Cucumber 插件后。运行 .feature 文件,会报以下错误:

首先,除了在 pom.xml
加入cucumber的依赖,还要增加下面这一段:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-jvm</artifactId>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
然后,在 Run Configuration 里,修改 Main Class 和 Arguments,如下图所示:

打开运行配置界面:

修改 Main Class 为:
io.cucumber.core.cli.Main
修改 Program arguments 为:
--plugin org.jetbrains.plugins.cucumber.java.run.CucumberJvm5SMFormatter
修改后重新运行测试,运行成功!
Cucumber 官方的说明请参考:https://cucumber.io/docs/cucumber/api/#from-the-command-line
我估计这是 Cucumber 插件和 Cucumber 旧版本的版本兼容 Bug,不知道官方什么时候做兼容性修复,我所用的版本是6.8.1。
网友评论