【问题标题】:Filtering with multiple metafilters in JBehave在 JBehave 中使用多个元过滤器进行过滤
【发布时间】:2012-07-29 08:09:38
【问题描述】:

情况:

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

示例:
xyz-cellphone-call.story 将是描述用手机拨打电话的故事。
xyz-phone-call.story 将是描述使用固定电话拨打电话的故事。
xyz-cellphone-browse.story 将是描述用手机浏览互联网的故事。

我的问题: 在 Jbehave 中,您可以添加 metaFilters 以根据元标记过滤故事。假设标签是@product & @action。 (@product 手机,@action 通话)。
是否可以通过过滤器来运行有关电话和手机故事的 JBehave 故事,如果可以,语法是什么?

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

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

动作也一样。

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

【问题讨论】:

    标签: java selenium filtering jbehave


    【解决方案1】:

    怎么样:

    mvn clean install -P -Djbehave.meta.filter = "+product cellphone&&phone"
    

    【讨论】:

      【解决方案2】:

      我猜你使用 groovy 有更简单的解决方案 http://jbehave.org/reference/stable/meta-filtering.html

      在你的情况下 -Dmetafilter="groovy: "product=='手机' && action=='call'"

      我将此功能文件尝试为“-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】:

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

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

        MetaFilter.DefaultMetaMatcher 将过滤器解释为一个序列 任何名称-值属性(以空格分隔),以“+”为前缀 包含,“-”代表排除。例如:

        MetaFilter filter = new MetaFilter("+author Mauro -theme 烟雾测试 +map *API -skip"); filter.allow(new Meta(asList("map someAPI")));

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

        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

        【讨论】:

        • 好的,我将不得不重试此操作,但过去我尝试过过滤器“+产品电话+行动电话”,但没有成功。
        • @HPacquee 我更新了答案,我认为现在更准确。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-08-06
        • 1970-01-01
        • 2020-02-12
        相关资源
        最近更新 更多