0

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 '20 at 9:06
  • What is the exact exception? Maybe the driver is not created in your TestBase Nov 27 '20 at 10:21
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 '20 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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