0

When I run to run this test with a feature it complains it cannot find the steps. I have tried defining them in Java 8 style, and Java 7 style and using IntelliJ to generate the steps into a MyStepdefs class but it cannot find them.

I am using version 1.2.4 of cucumber-java8 and cucumber-junit.

import cucumber.api.CucumberOptions;
import cucumber.api.DataTable;
import cucumber.api.PendingException;
import cucumber.api.java8.En;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
        monochrome = true,
        glue = {"com.mycom.core.agg.RunCukesTest"})
public class RunCukesTest implements En {

    public RunCukesTest() {
        Given("^I have PriceLevels$", (DataTable arg1) -> {
        });

        And("^I have a TradeRequest$", (DataTable arg1) -> {
        });

        Then("^I should get these LegRequests$", (DataTable arg1) -> {
        });
    }
}

running the test prints

Running com.mycom.core.agg.RunCukesTest

1 Scenarios (1 undefined)
3 Steps (3 undefined)
0m0.000s


You can implement missing steps with the snippets below:

Given("^I have PriceLevels$", (DataTable arg1) -> {
.. rest deleted ...

Running the feature file from IntelliJ give much the same error.

1 Answer 1

1

While we couldn't figure out what the cause was, create a new maven project with a minimum of dependencies "fixed" the problem. We didn't need to change the code.

Sign up to request clarification or add additional context in comments.

2 Comments

The problem you faced was a classpath that didn't contain the expected steps. Creating a Maven project will also create a classpath that contains features and steps if you locate them in src/test/resources/<your package>/*.feature and src/test/java/<package>/*.java. The expected result is that the steps will be found. As you got.
@ThomasSundberg The paths of the features and steps is the same in the first project as the second. I even used the idea to put in the steps and the plugin said that it could find a match. It appears to have been a conflict with a dependency as even if I used examples from the github/cucumber I got the same error until I created a new project.

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.