-3

i am getting null pointer execption when executing scenarios from runner class. when i execute from feature file then tests are executed without any error, I am using tags to run the scenarios and i have mentioned the tags in runner class, please let me know what might be the reason.

Runner Class Code:

@RunWith(Cucumber.class) 
@CucumberOptions( features={"Features"} ,glue={"project.stepdef"} ,tags = {"@chrome","@smoke"} , format = {"pretty", "html:target/site/cucuber-pretty","json:target/site/cucumber.json"} // ,monochrome = true ) 
public class CucumberRunner 
{ 

}
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Try [this](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – soufrk Jun 07 '18 at 13:27
  • Hi soufrk, thanks but i am not getting null pointer when i run the feature file, i am only getting it when i try and run the Runner class – tester automation Jun 07 '18 at 13:44
  • could you please paste some code from runner class? – Vinit Mehta Jun 07 '18 at 13:48
  • @RunWith(Cucumber.class) @CucumberOptions( features={"Features"} ,glue={"project.stepdef"} ,tags = {"@chrome","@smoke"} , format = {"pretty", "html:target/site/cucuber-pretty","json:target/site/cucumber.json"} // ,monochrome = true ) public class CucumberRunner { } – tester automation Jun 07 '18 at 13:49
  • Can you please add correctly formatted code to your question. From your comment above it seems you are commenting out (`//`) something in your runner? – Marit Jun 11 '18 at 11:58

1 Answers1

0

You need to make some minor tweaks to the runner Class as follows:

import org.junit.runner.RunWith;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class) 
@CucumberOptions( 
                    features="Features",
                    glue="stepdef",
                    tags = {"@chrome","@smoke"}, 
                    plugin = {"html:target/cucumber-html-report", 
                              "pretty:target/cucumber-pretty.text",
                              "json:target/cucumber.json"},
                ) 
public class CucumberRunner {}
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352