1

I am getting the exception in subject on IntelliJ and have no idea why.

Project structure

This is the runner file:

@RunWith(Cucumber.class)
@CucumberOptions(
        features = "src/main/resources/features",
        glue = {"DemoDefinitions"},
        tags = "@tests"
        )
public class CucumberRunner {}

This is the definitions file:

import cucumber.api.java.en.Given;

public class DemoDefinitions {

    @Given("Login to Azure Succeeded")
    public void login_to_Azure_Succeeded() {
        // Write code here that turns the phrase above into concrete actions
        throw new cucumber.api.PendingException();
    }
}

This is the feature file:

@tests

Feature: PoC Feature

  Scenario: PoC Operations Scenario
    Given Login to Azure Succeeded

And the maven dependencies are:

<dependencies>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-core</artifactId>
        <version>4.4.0</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>4.2.6</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>4.2.6</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
    </dependency>
</dependencies>

When I run execute the runner class I get:

java.lang.NoSuchMethodError: cucumber.runtime.formatter.Plugins.(Ljava/lang/ClassLoader;Lcucumber/runtime/formatter/PluginFactory;Lcucumber/api/event/EventPublisher;Lio/cucumber/core/options/PluginOptions;)V

When I run the feature file itself I get:

Undefined scenarios: /C:/Users/talt/IdeaProjects/Poc/src/main/resources/features/poc.feature:5 PoC Operations Scenario

1 Scenarios (1 undefined) 1 Steps (1 undefined)

Can you please advise what is the problem?

3 Answers 3

2

You are mixing different versions of Cucumber. Take a careful look at the version numbers.

You are also including more dependencies then strictly needed. Merely using cucumber-java and cucumber-junit would be sufficient. Both cucumber-core and junit are transitive dependencies.

After you fix your dependencies makes sure to reimport the maven project.

<dependencies>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>4.4.0</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>4.4.0</version>
    </dependency>
</dependencies>
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks mpkorstanje. It didn't make the change. However I found out the error and fixed it. See my answer.
You should still clean up your imports though.
2

We shall not mix direct & transitive dependencies, specially their versions! Doing so can cause unpredictable outcome.Below are few errors being reported by people due to wrong use of dependencies.

  • The import cucumber.api.junit cannot be resolved
  • java.lang.NoClassDefFoundError: gherkin/IGherkinDialectProvider
  • import cucumber.api.DataTable; cannot be resolved

Solution: You shall add right set of cucumber dependencies.

    <dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>4.2.6</version>
    <scope>test</scope>
    </dependency>

    <dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-picocontainer</artifactId>
    <version>4.2.6</version>
    <scope>test</scope>
    </dependency>

Second you could say we did not have correct path pointing to glue. But just making it empty shall not be one of the solution even though it worked. We shall have correct path here, not empty string.

Comments

1

The solution was to set glue to empty string:

glue = {""}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.