[英]How can I run cucumber without any feature file?
我正在使用Cucumber為BDD,JUnit和Selenium構建一個自動化框架,我們在雲中有一個testrail實例用於測試管理,並且我實現了testrail API以從那里獲取所有測試用例,問題是我無法運行這些步驟以獲取測試用例,因為cucumber
始終會驗證第一個功能文件的存在。
我已經嘗試過@Before (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 ###");
}
}
這是鈎子類:
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);
}
}
我不確定您要實現的目標,但它認為您正在尋找的是@BeforeSuite
批注(使用import注解@BeforeSuite
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.