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 {

}
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) Nov 27, 2020 at 9:06
  • What is the exact exception? Maybe the driver is not created in your TestBase 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

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 {

}
1
  • runner package has cucumber hooks , so that is needed. without that my "@Before" and '@After' hooks wont run 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.