Warm tip: This article is reproduced from serverfault.com, please click

Cucumber JUnit tests not gluing feature to stepdefinitions

发布于 2019-09-05 15:28:59

I have setup a cucumber project in java, in my Eclipse IDE I am able to run my feature file directly and the tests will complete. However when I run them as JUnit tests they don't run, in the console they appear as

@When("^user navigates to Login Page$")
public void user_navigates_to_Login_Page() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

and if I double click the step in the JUnit tab I get the following message

"Test class not found in selected Project"

My test runner class looks like this,

package com.bsautoweb.runner;

import java.io.File;

import org.junit.AfterClass;
import org.junit.runner.RunWith;

import com.cucumber.listener.Reporter;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(glue = {"src/test/java/com/bsautoweb/stepdefinitions"}, features = {"src/test/resources/features/"},
plugin = "com.cucumber.listener.ExtentCucumberFormatter:target/cucumber-reports/report.html",
monochrome = true
)

public class Testrunner {
    @AfterClass
    public static void writeExtentReport() {
        Reporter.loadXMLConfig(new File("config/report.xml"));

    }
}

My folder structure looks like this

folder structure

It seems that JUnit is ignoring my glue code. Even if I enter an invalid path, it doesn't complain.

Questioner
Ethranes
Viewed
0
Grasshopper 2019-09-06 22:23:00

Set the glue option as com/bsautoweb/stepdefinitions or as java package style com.bsautoweb.stepdefinitions