1

The cucumber feature file has all steps highlighted in yellow and warning is shown as step does not have matching glue code, When I try to run the project as maven test, I am getting null pointer exception for all steps.

TestRunner[Feature[Steps][2]

Login.feature

Test Runner class:

package com.vtiger.CucumberFramework.testRunner;
import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(
 features = "classpath:features",
 glue = {"com.vtiger.CucumberFramework.stepDefinitions","com.vtiger.CucumberFramework.testRunner"}, 
 plugin = { "pretty","html:target/cucumber-reports/cucumber-pretty", 
 "json:target/cucumber-reports/CucumberTestReport.json",
 "rerun:target/cucumber-reports/rerun.txt" },
 monochrome = true)
public class TestRunner {
}
Mate Mrše
4,1194 gold badges25 silver badges51 bronze badges
asked Nov 26, 2020 at 19:31
2
  • 1
    Not a Cucumber expert, but you have a space before the $ in your step definitions. Maybe it is causing the pattern to not match. (If that's the case, I will transform this comment in an answer to be accepted) Commented Nov 27, 2020 at 9:06
  • What is the exact exception? Maybe the driver is not created in your TestBase Commented Nov 27, 2020 at 10:21

3 Answers 3

1

make sure you have installed cucumber for eclipse from market place:

https://marketplace.eclipse.org/content/cucumber-eclipse-plugin

Goto preference and search for cucumber and enable step detection

enter image description here

answered Nov 28, 2020 at 13:37
0

The "glue" Cucumber option specifies the package where the step definition files are located. I don't think you need the runner package.

Try this:

@RunWith(Cucumber.class)
@CucumberOptions(
 features = "classpath:features",
 glue = "com.vtiger.CucumberFramework.stepDefinitions", 
 plugin = { "pretty","html:target/cucumber-reports/cucumber-pretty", 
 "json:target/cucumber-reports/CucumberTestReport.json",
 "rerun:target/cucumber-reports/rerun.txt" },
 monochrome = true)
public class TestRunner {
}
answered Nov 27, 2020 at 11:51
1
  • runner package has cucumber hooks , so that is needed. without that my "@Before" and '@After' hooks wont run Commented Nov 28, 2020 at 15:48
0

I faced a similar issue occasionally, Cucumber files fail to point to the associated step definition files even if it was working flawlessly previously.

One little hack is to go to the associated step definition class -> Make a harmless/Dummy modification -> Save the class file.

Now the eclipse feature files have no "Step does not have matching glue code" errors.

answered Dec 22, 2022 at 11:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.