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]
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 {
}
-
1Not 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)João Farias– João Farias2020年11月27日 09:06:09 +00:00Commented Nov 27, 2020 at 9:06
-
What is the exact exception? Maybe the driver is not created in your TestBaseNiels van Reijmersdal– Niels van Reijmersdal2020年11月27日 10:21:31 +00:00Commented Nov 27, 2020 at 10:21
3 Answers 3
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
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 {
}
-
runner package has cucumber hooks , so that is needed. without that my "@Before" and '@After' hooks wont runAnjani Kumar– Anjani Kumar2020年11月28日 15:48:36 +00:00Commented Nov 28, 2020 at 15:48
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.