情况:
在我目前的项目中,我们正在运行各种不同的JBehave故事。每个“.story”文件都与产品和流程相关。
示例:
xyz-cellphone-call.story将描述用手机拨打电话的故事
xyz-phone-call.story将描述用固定电话拨打电话的故事
xyz-cellphone-browse.story将描述用手机浏览互联网的故事。
我的问题: 在Jbehave中,您可以添加metaFilters以基于元标记过滤故事。假设标签是@product& @行动。 (@product mobile,@ action call。) 是否可以通过过滤器来运行有关手机和手机的JBehave故事?手机故事,如果是,那会是什么语法?
我已尝试添加以下过滤器(均无效):
+product cellphone +product phone
+product cellphone|phone
+product cellphone,phone
同样的行动。
是否可以过滤多个元标记?
答案 0 :(得分:1)
是的,这是可能的。 在API文档中,您将找到以下信息:
过滤器由其String表示唯一标识,即 MetaFilter.MetaMatcher解析并匹配以确定是否 Meta是否允许。
MetaFilter.DefaultMetaMatcher将过滤器解释为序列 任何名称 - 值属性(由空格分隔),以" +"为前缀 包含和" - "排除。 E.g:
MetaFilter过滤器=新的MetaFilter(" +作者Mauro -theme烟雾测试 + map * API -skip"); filter.allow(new Meta(asList(" map someAPI")));
MetaFilter.GroovyMetaMatcher的使用由前缀触发 "常规:"并允许将过滤器解释为Groovy 表达
MetaFilter过滤器=新的MetaFilter(" groovy :( a ==' 11' | a ==' 22') &安培;&安培; b ==' 33'");
因此,如果您使用条件,则可以自定义运行配置。 试试这个例子:
mvn clean install -P -Djbehave.meta.filter =" myCustomRunConf:(+ product&& + action)"
更多信息,请参阅API文档中的MetaFilter类: http://jbehave.org/reference/stable/javadoc/core/org/jbehave/core/embedder/MetaFilter.html
答案 1 :(得分:0)
我想使用groovy有更简单的解决方案 http://jbehave.org/reference/stable/meta-filtering.html
在你的情况下,它会 -Dmetafilter =" groovy:"产品=='手机' &安培;&安培;动作=='调用'"
我试过它" -Dmetafilter = groovy:t2&& T3"对于此功能文件
Meta:
@t1
Narrative:
As a user
I want to blah-blah-blah
Scenario: test 1
Meta:
@t2
Given I am on home page
Scenario: test 2
Meta:
@t2
@t3
Given I am on home page
Scenario: test 3
Meta:
@t3
Given I am on home page
在这种情况下只执行测试2场景
答案 2 :(得分:0)
怎么样:
mvn clean install -P -Djbehave.meta.filter = "+product cellphone&&phone"