Cucumber: Unable to find step definition

It looks like Cucumber isn't finding your step defintion class. In your unit test class you say:

 glue = {"com.macro.definition"}

However the step definition classes are in com.test.definition

Try changing that line to:

 glue = {"com.test.definition"}

You may have to rebuild your project to pick up the change.


Also, Cucumber is sensitive to white space. If you try to make your runner or feature file pretty after having captured the snippets, you will get this problem.

Here's an example that drove me nuts for several hours while creating my first BDD. I had created the feature file and a skeleton runner which I ran and and captured the snippets. Then I prettified the feature file, and when I ran the runner got the errors.

Of course everything looked fine to my human brain, so the next few hours were spent in fruitless research here, and checking versions and bug lists. Finally I decided to compare the first two lines of the snippet to see what was different:

//  @Then("^the test result is = \"([^\"]*)\"$")
//  public void theTestResultIs(String ruleResult) throws Throwable {
    @Then("^the test result is         = \"([^\"]*)\"$")
    public void theTestResultIs(String arg1) throws Throwable {

Doh!