Reputation: 1
I'm building an automation framework using Cucumber for BDD, JUnit and Selenium, we have a testrail instance in the cloud for test management and I implemented the testrail API for getting all the test cases from there, the problem is I'm not able to run these steps for getting the test cases because cucumber
always validate first feature file exist.
I've tried with @Before (Cucumber)
, @BeforeClass (JUnit)
and the result is always the same:
No features found at [classpath:features] 0 Scenarios 0 Steps 0m0.019s
This is the main class starting the process:
import cucumber.api.CucumberOptions;
import cucumber.api.java.Before;
import cucumber.api.junit.Cucumber;
import org.apache.log4j.Logger;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import static
com.mps.framework.support.support.Property.BROWSER_NAME;
@RunWith(Cucumber.class)
@CucumberOptions(
plugin = "json:target/cucumber.json",
features = {"classpath:features"},
glue = {"com.selenium.test.stepdefinitions", "com.mps.selenium.hook"},
tags = {"not @ignore"})
public class SeleniumCukes {
private static final Logger LOG = Logger.getLogger(SeleniumCukes.class);
@BeforeClass
public static void startSelenium() {
LOG.info("### Starting Selenium " +
BROWSER_NAME.toString().toUpperCase() + " ###");
}
@AfterClass
public static void stopSelenium() {
LOG.info("### Stopping Selenium ###");
}
}
This is the hooks class:
import com.mps.selenium.base.SeleniumBase;
import cucumber.api.Scenario;
import cucumber.api.java.After;
import cucumber.api.java.Before;
import org.springframework.beans.factory.annotation.Autowired;
import static com.mps.framework.support.hook.Hooks.hookAfter;
import static com.mps.framework.support.hook.Hooks.hookBefore;
public class Hooks {
@Autowired
private SeleniumBase seleniumBase;
@After
public void after() {
hookAfter(seleniumBase.getDriver());
}
@Before
public void before(Scenario scenario) {
hookBefore(scenario);
}
}
Upvotes: 0
Views: 1172
Reputation: 90
I'm not sure what you are trying to achieve but it think what you are looking for is the annotation @BeforeSuite
(use the import annotations.BeforeSuite)
Upvotes: 1