有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

JBehave中具有多个元过滤器的java过滤

情况:

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

示例:
xyz手机电话。故事就是用手机打电话的故事
xyz电话。故事就是用固定电话打电话的故事
xyz手机浏览。故事将是描述用手机浏览互联网的故事

我的问题: 在Jbehave中,您可以添加元过滤器,以根据元标记过滤故事。假设标签是@product&@行动(@product手机,@action call)
有没有可能通过一个过滤器来运行关于手机和手机的JBehave故事;手机故事,如果是,语法是什么

我尝试添加了以下过滤器(均无效):

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

行动也是如此

可以过滤多个元标记吗


共 (3) 个答案

  1. # 1 楼答案

    那么:

    mvn clean install -P -Djbehave.meta.filter = "+product cellphone&&phone"
    
  2. # 2 楼答案

    我想使用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场景

  3. # 3 楼答案

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

    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.

    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")));

    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'");

    因此,如果你能适应这些条件,你可能会定制跑步配置。 试试这个例子:

    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