George Codreanu
George Codreanu

Reputation: 23

Cucumber - Unable to run tests using runner

Issue: When trying to run the cucumber runner class in order to test specifics tests (by tag), the tests will not run. The following messages will be received:

    Feature: Homepage

Test ignored.

Test ignored.

  @Testone
  Scenario: whateves     # Homepage_TC.feature:4
    Given printsomething

1 Scenarios (1 undefined)
1 Steps (1 undefined)
0m0.000s


You can implement missing steps with the snippets below:

@Given("^printsomething$")
public void printsomething() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}


Process finished with exit code 0

Running the feature file will work just fine. Below you can find the runner.

@CucumberOptions(features = "src/INGPSD2/main/resources/",
                 format = {"pretty", "html:target/cucumber",},
                glue = "src/INGPSD2/test/java/Steps",
                 tags = {"@Testone"})
@RunWith(Cucumber.class)
public class runnerCucumber { }

Hooks class:

public class Hooks {
private static List<DriverFactory> webDriverThreadPool = Collections.synchronizedList(new ArrayList<DriverFactory>());
private static ThreadLocal<DriverFactory> driverFactory;
public SoftAssert softAssert = new SoftAssert();

@Before
public static void instantiateDriverObject() {
    driverFactory = new ThreadLocal<DriverFactory>() {
        @Override
        protected DriverFactory initialValue() {
            DriverFactory driverFactory = new DriverFactory();
            webDriverThreadPool.add(driverFactory);
            return driverFactory;
        }
    };
}

public static WebDriver getDriver() throws Exception {
        return driverFactory.get().getDriver();

}

// ----------------- SETUP

// -----------------------

@After
public static void closeDriverObjects() throws Exception {
    getDriver().manage().deleteAllCookies();
    for (DriverFactory driverFactory : webDriverThreadPool) {
        driverFactory.quitDriver();
    }
}

}

Please let me know if i can provide more information as this issue is really annoying and i couldnt find anything yet that could help.

Upvotes: 2

Views: 3410

Answers (1)

nick318
nick318

Reputation: 575

You have a mistake defining glue. You should use package name instead of path to steps.java.
So change glue = "src/INGPSD2/test/java/Steps" to glue = "package_name" where your class with steps is located.

Upvotes: 2

Related Questions