Cucumber not Finding Step Definitions Java

Profile picture for user devraj

There is possibility when you are running your feature file using Cucumber Runner class or any other technique you get message during execution "You can implement missing steps with the snippets below:"

Sometime it may surprise you that your steps exist but it does not work.

Please follow below solutions to get rid of this error:

Solution 1: Convert to cucumber project

Step 1: Right click on eclipse project go to Configure -> Convert to cucumber project

Step 2: Project -> Clean

Solution 2: Add glue code to Cucumber Runner class

In your JUnit Test runner class, add path to package where your step definition class file is, e.g:

@CucumberOptions(
		plugin = {"pretty", "html:target/cucumber"},
		features = {"src/test/resources/features"},
		glue={"com.pb.cucumberdemo.stepdefinitions"},
		monochrome = true,
		tags = {"@smoke"}		
	 )

add line starts with glue, here com.pb.cucumberdemo.stepdefinitions is my package name you can replace it with yours. Do not add class name in glue code.

Solution 3: Replace your annotation step line with one in console

Avoid typing and use copy paste to avoid manual issues. You can copy similar line like below from console and replace it with existing line in step definition class file, even if it look similar but sometime does not work:

@When("^I filled in \"([^\"]*)\" with \"([^\"]*)\" on \"([^\"]*)\" page$")

Stupid but sometimes works.

Solution 4: Update Plugin

Step 1: Go to Eclipse -> About Eclipse -> Installation Detail

Problems occurred when invoking code from plug-in: "org.eclipse.jdt.core".

Step 2: Select Cucumber Eclipse Plugin then click on Update

Problems occurred when invoking code from plug-in: "org.eclipse.jdt.core".