Reputation: 1478
I'm using IntelliJ Idea Ultimate 2018.1 and in my java project, I've some BDD implemented with Cucumber and Gherkin. when I try to right-click on a feature file and run it I see the following error
Exception in thread "main" java.lang.NoClassDefFoundError: gherkin/formatter/Formatter
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at cucumber.runtime.formatter.PluginFactory.loadClass(PluginFactory.java:174)
at cucumber.runtime.formatter.PluginFactory.pluginClass(PluginFactory.java:166)
at cucumber.runtime.formatter.PluginFactory.getPluginClass(PluginFactory.java:223)
at cucumber.runtime.formatter.PluginFactory.isStepDefinitionReporterName(PluginFactory.java:206)
at cucumber.runtime.RuntimeOptions$ParsedPluginData.addPluginName(RuntimeOptions.java:456)
at cucumber.runtime.RuntimeOptions.parse(RuntimeOptions.java:160)
at cucumber.runtime.RuntimeOptions.<init>(RuntimeOptions.java:112)
at cucumber.runtime.RuntimeOptions.<init>(RuntimeOptions.java:105)
at cucumber.runtime.RuntimeOptions.<init>(RuntimeOptions.java:97)
at cucumber.api.cli.Main.run(Main.java:30)
at cucumber.api.cli.Main.main(Main.java:18)
Caused by: java.lang.ClassNotFoundException: gherkin.formatter.Formatter
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
This is happening for some days. In the past was working perfectly. The cucumber for java and gherkin plugins are installed. I've tried to download a new fresh version of IntelliJ but no luck.
The dependencies I've in my project are the following
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-spring</artifactId>
<version>${cucumber.version}</version>
</dependency>
and my feature file is similar to the following
Feature: Blocker Accumulation
Scenario: Blocker Accumulation
Given I am logged as a user
And I have an In-progress activity
And it has been previously blocked for 16 days
And now is not blocked
When I block the activity for other more 6 days
Then the total blocking days is 22
What can I try? What's my fault? Thank you
Upvotes: 0
Views: 7119
Reputation: 1478
The problem was a compatibility issue between cucumber 3 and the intelliJ cucumber plugin.
In order to make everything working I have changed the cucumber.version value from 3.0.2 to 2.4.0.
Upvotes: 1
Reputation: 3026
You'll need to update your Cucumber for Java plugin. (This may include uninstall/install to get it to work correctly).
Upvotes: 1
Reputation: 9058
You will need to add a few other dependencies. You are missing the gherkin.jar
.
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>gherkin-jvm-deps</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>gherkin</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>tag-expressions</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
<version>${cucumber.version}</version>
</dependency>
If you need java-8 support for lambda style stepdefs add cucumber-java8
dependency.
Upvotes: 0