Search code examples
seleniumjunitcucumbercucumber-junitselenide

Junit Runner doesn't run Cucumber feature


When I debug it, only @BeforeClass config works - it opens browser and go to google.com, also in Console I can see Scenarios of my feature, so Runner see it. All of them says "Test ignored". If I debug features (not throught Runner), they work. How can I run/debug them (one at a time) from my Runner? Please, help me to find mistake

My Runner:

   package Runners;

   import com.codeborne.selenide.Configuration;
   import com.codeborne.selenide.WebDriverRunner;
   import cucumber.api.CucumberOptions;
   import cucumber.api.junit.Cucumber;
   import org.junit.BeforeClass;
   import org.junit.runner.RunWith;
   import org.openqa.selenium.WebDriver;

   import static com.codeborne.selenide.Selenide.open;
   import static com.codeborne.selenide.Selenide.sleep;


   @RunWith(Cucumber.class)
   @CucumberOptions(
    features = {"src/test/java/Features"},
    tags = {"@smokeTest#1"},
    glue = "src/test/java/Steps"

   )

   public class Runner {

       @BeforeClass
       static public void Initialization() {
           Configuration.timeout = 1500;
           Configuration.startMaximized = true;
           System.setProperty("webdriver.chrome.driver",                      
    "src\\test\\repository\\webDriver\\chromedriver.exe");
           Configuration.browser = "chrome";
           Configuration.savePageSource = false;
           Configuration.holdBrowserOpen = false;

           open("https://www.google.ru");


           Configuration.savePageSource = false;

       }


   }

Solution

  • As per @grasshopper suggested on comments, the glue option should be in package format.

    E.g: If your step definitions are directly under src/test/java/steps you should go with:

    @CucumberOptions(features = {"src/test/java/features"}, glue = {"steps"})
    

    In other hand, if your step definitions are under more than one package (e.g.: src/test/java/your.package.steps), you should have something like this:

    @CucumberOptions(features = {"src/test/java/features"}, glue = {"your.package.steps"})