作者:Hongquan_Yang | 来源:互联网 | 2022-12-16 11:48
当我在IntelliJ中运行黄瓜测试功能时,它显示的是带有堆栈跟踪的IncompatibleClassChangeError:
Testing started at 12:55 ...
/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin/java ...
Exception in thread "main" java.lang.IncompatibleClassChangeError: Found interface cucumber.api.TestCase, but class was expected
at org.jetbrains.plugins.cucumber.java.run.CucumberJvm2SMFormatter.handleTestCaseStarted(CucumberJvm2SMFormatter.java:80)
at org.jetbrains.plugins.cucumber.java.run.CucumberJvm2SMFormatter.access$000(CucumberJvm2SMFormatter.java:17)
at org.jetbrains.plugins.cucumber.java.run.CucumberJvm2SMFormatter$1.receive(CucumberJvm2SMFormatter.java:32)
at org.jetbrains.plugins.cucumber.java.run.CucumberJvm2SMFormatter$1.receive(CucumberJvm2SMFormatter.java:30)
at cucumber.runner.EventBus.send(EventBus.java:28)
at cucumber.runner.TestCase.run(TestCase.java:37)
at cucumber.runner.Runner.runPickle(Runner.java:44)
at cucumber.runtime.Runtime.runFeature(Runtime.java:120)
at cucumber.runtime.Runtime.run(Runtime.java:106)
at cucumber.api.cli.Main.run(Main.java:35)
at cucumber.api.cli.Main.main(Main.java:18)
Process finished with exit code 1
Empty test suite.
这是IntelliJ IDEA 2018.1.4 (Ultimate Edition), Build #IU-181.5087.20
,与Cucumber for Java version 181.5087.20
1> guleryuz..:
如问题#1392中所述
这是由IDEA的CucumberJvm2SMFormatter引起的.它是Cucumber2的格式化程序,在Cucumber 3中遇到了一个突破性的变化.
最简单的解决方法是--plugin org.jetbrains.plugins.cucumber.java.run.CucumberJvm2SMFormatter
从运行配置中删除程序参数.
2> beetstra..:
这是在最新版本中解决的.
您可以重新创建配置(因此它将自动更新),或者您可以使用替换程序参数
--plugin org.jetbrains.plugins.cucumber.java.run.CucumberJvm3SMFormatter
旧版本的插件与黄瓜java版本3及更高版本不兼容.如果您遇到那个问题,可以更新build.gradle以明确指定版本2:
dependencies {
...
testCompile 'io.cucumber:cucumber-java8:2.+'
}