在JBehave中使用多个元过滤器进行过滤 [英] Filtering with multiple metafilters in JBehave

查看:129
本文介绍了在JBehave中使用多个元过滤器进行过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情境:

在我目前的项目中,我们正在运行各种不同的JBehave故事。每个.story文件都与产品和流量相关。

In my current project we are running all kinds of different JBehave stories. Every ".story" file is related to a product and a flow.

示例:

xyz-cellphone- call.story将描述用手机拨打电话的故事。

xyz-phone-call.story将描述用固定电话拨打电话的故事。

xyz-cellphone-browse.story将描述用手机浏览互联网的故事。

Example:
xyz-cellphone-call.story would be the story describing making a phonecall with a cellphone.
xyz-phone-call.story would be the story describing making a phonecall with a fixed-line phone.
xyz-cellphone-browse.story would be the story describing browsing the internet with a cellphone.

我的问题:
In Jbehave你可以添加metaFilters来过滤基于元标记的故事。假设标签是@product& @行动。 (@product手机,@ action电话)。

是否可以通过过滤器来运行有关电话和电话的JBehave故事?手机故事,如果是的话,会是什么语法?

My question: In Jbehave you can add metaFilters to filter on the stories based on meta tags. Assume the tags are @product & @action. (@product cellphone, @action call).
Would it be possible to pass a filter to run the JBehave stories concerning both the phone & cellphone stories, if yes, what would be the syntax?

我尝试添加以下过滤器(没有一个工作):

I've tried adding the following filters (none of which work):

+product cellphone +product phone
+product cellphone|phone
+product cellphone,phone

行动相同。

是否可以过滤多个元标记?

Is it possible to filter on multiple meta-tags?

推荐答案

是的,这是可能的。
在API文档中,您将找到以下信息:

Yes it is possible. In the API docs you will find this information:


过滤器由其String表示唯一标识,即
由MetaFilter.MetaMatcher解析和匹配,以确定是否允许
Meta。

A filter is uniquely identified by its String representation which is parsed and matched by the MetaFilter.MetaMatcher to determine if the Meta is allowed or not.

MetaFilter.DefaultMetaMatcher将过滤器解释为序列
任何名称 - 值属性(由空格分隔),前缀为+
包含, - 用于排除。例如:

The MetaFilter.DefaultMetaMatcher interprets the filter as a sequence of any name-value properties (separated by a space), prefixed by "+" for inclusion and "-" for exclusion. E.g.:

MetaFilter filter = new MetaFilter(+ author Mauro -theme smoke testing
+ map * API -skip); filter.allow(new Meta(asList(map someAPI)));

MetaFilter filter = new MetaFilter("+author Mauro -theme smoke testing +map *API -skip"); filter.allow(new Meta(asList("map someAPI")));

使用MetaFilter.GroovyMetaMatcher由前缀
触发groovy :并允许将过滤器解释为Groovy
表达式。

The use of the MetaFilter.GroovyMetaMatcher is triggered by the prefix "groovy:" and allows the filter to be interpreted as a Groovy expression.

MetaFilter filter = new MetaFilter(groovy:(a =='11'| a == '22')
&& b == '33');

MetaFilter filter = new MetaFilter("groovy: (a == '11' | a == '22') && b == '33'");

所以可能如果您玩这些条件,您将获得自定义的运行配置。
试试这个例子:

So probably if you play with the conditions, you will get your run configuration customized. Try this example:


mvn clean install -P -Djbehave.meta.filter =myCustomRunConf:(+ product& & + action)

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

More info amout the MetaFilter class in the API docs: http://jbehave.org/reference/stable/javadoc/core/org/jbehave/core/embedder/MetaFilter.html

这篇关于在JBehave中使用多个元过滤器进行过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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