繁体   English   中英

没有任何功能文件的情况下如何运行黄瓜?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM