黄瓜选项注释 [英] Cucumber options annotation

查看:173
本文介绍了黄瓜选项注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

cucumber-jvm javadocs a>说明了粘贴元素的目的是指定步骤定义和钩子的位置。但是,这似乎并不适用于我。假设我有我的功能在目录a,我的步骤定义在目录b。然后,

The cucumber-jvm javadocs states that purpose of the glue element is to specify the location of the stepdefinitions and hooks. However, this doesn't seem to work for me. Lets say I have my features in directory a, and my step definitions in directory b. Then,

@Cucumber.Options(
        features= "directory_a", 
            glue="directory_b"
)

将从directory_a加载我的要素文件,从direct_b的步骤定义。但是,如果我使用

will load my feature files from directory_a, but, it doesn't load my step definitions from directly_b. However, if I use

@Cucumber.Options(
        features= {"directory_a", "directory_b"}
)

然后我从directory_a加载我的功能,向上。这正是我想要的,但是,我不明白为什么前者不工作?我猜它有一些与它期望URI的格式不同(也许我需要预先一个类路径或类似的东西),但我找不到任何信息在文档中。 / p>

then my features from directory_a is loaded, and my step definitions from directory_b are also picked up. Which is exactly what I want, however, I don't understand why the former isn't working? I'm guessing it has something to do with it expecting the URI to be formatted differently (maybe i need to prepend a classpath:// or something like that), but I can't find any information on this in the documentation.

推荐答案

我已经成功使用了类似:

I have successfully used something like:

@RunWith(Cucumber.class)
@Cucumber.Options(
    //this code will only look into "features/" folder for features
    features={"classpath:features/"},
    glue = { "com.mycompany.cucumber.stepdefinitions", "com.mycompany.cucumber.hooks" },
    format = { "com.mycompany.cucumber.formatter.RuntimeInfoCatcher", "json:target/cucumber.json" },
    tags = { "@working" }
    )
public class CucumberStarterIT {
}

查看文档 http://cukes.info/api/cucumber/jvm/javadoc/cucumber/api/junit/Cucumber.Options.html ,它将选项指定为类型 String [] 所以也许不希望工作好,如果你不给它一个单值列表。尝试 glue = {directory_b} ,看看会发生什么。

Looking at the doc at http://cukes.info/api/cucumber/jvm/javadoc/cucumber/api/junit/Cucumber.Options.html it specifies the options to be of type String[] so perhaps it's not expected to work "well" if you don't give it a single-value list. Try glue={"directory_b"} and see what happens for you.

这篇关于黄瓜选项注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆