Cucumber cannot find StepDefinitions while running the code but manually using the option "Find Step" can find step definition


In the project Structure defined like below,

  • src/main/java
    — Config (
    — StepDefinitions
  • src/test/resources
    — features/loginenter image description here

When I run from using RunAs --> JUnit Test, Step Definitions cannot be found by runner

When I click find Step, opens the right file. Couldn’t understand where the issue is because the code was running few days back. File is downloaded from here

Runner class code

package helpers;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
//features= "src/test/resources/features/navigation",

        features = {"classpath:features"},
        plugin = {"pretty", "html:target/cucumber-html-report"},
        tags = {"@OnlyOneTime"},
//      dryRun = true,
        monochrome = true
public class RunCukesTest{



Glue code is supposed to have path to hooks and step definitions

So modified as glue={"helpers","stepDefinitions"} instead of
glue={"helpers","classpath/stepDefinitions", "classpath/stepDefinitions.LogIn","classpath/stepDefinitions.Publish"}

Please refer to this link Similar issue on github

Answered By – Nagarjuna Reddy

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published