我正在使用针对BDD,JUnit和Selenium的Cucumber构建自动化框架,我们在云中有一个testrail实例用于测试管理,并且我实现了testrail API以从那里获取所有测试用例,问题是我无法执行这些步骤来获取测试用例,因为cucumber
始终会验证第一个功能文件是否存在。
我尝试使用@Before (Cucumber)
,@BeforeClass (JUnit)
,结果始终是相同的:
在[classpath:features]找不到功能 0场景 0步 0m0.019s
这是开始该过程的主要类:
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 ###");
}
}
这是hooks类:
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);
}
}
答案 0 :(得分:0)
我不确定您要实现的目标,但它认为您正在寻找的是注释@BeforeSuite
(使用import注解。BeforeSuite)