beetstra
beetstra

Reputation: 7952

IncompatibleClassChangeError running Cucumber tests in IntelliJ

When I run a cucumber test feature in IntelliJ, all it shows is an IncompatibleClassChangeError with stack trace:

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.

This is IntelliJ IDEA 2018.1.4 (Ultimate Edition), Build #IU-181.5087.20, with Cucumber for Java version 181.5087.20

Upvotes: 14

Views: 7551

Answers (2)

beetstra
beetstra

Reputation: 7952

This is solved in the latest version.

You can recreate the configuration (so it will be updated automatically), or you can replace the program arguments with

--plugin org.jetbrains.plugins.cucumber.java.run.CucumberJvm3SMFormatter

An older version of the plugin was not compatible with cucumber java version 3 and higher. If you are stuck with that one you can update your build.gradle to specify version 2 explicitly:

dependencies {
    ...
    testCompile 'io.cucumber:cucumber-java8:2.+'
}

Upvotes: 8

Yilmaz Guleryuz
Yilmaz Guleryuz

Reputation: 9745

As explained in issue #1392

This is caused by IDEA's CucumberJvm2SMFormatter. It being the formatter for Cucumber2, runs into a breaking change in Cucumber 3.

The simplest workaround is removing --plugin org.jetbrains.plugins.cucumber.java.run.CucumberJvm2SMFormatter from program arguments in the run configuration.

Upvotes: 11

Related Questions