【问题标题】:JBehave: How to run specific set of stories from the whole collection in .story fileJBehave:如何在 .story 文件中运行整个集合中的特定故事集
【发布时间】:2017-05-15 10:19:00
【问题描述】:

假设我有一个Main.story 文件,其中包含-

  1. 登录场景
  2. 搜索场景
  3. AddToCart 场景
  4. UpdateQuantity 场景
  5. 结帐场景

但是现在如果我只想跑步怎么办-

Login Scenario → Search Scenario → AddToCart Scenario → Checkout Scenario 并跳过 UpdateQuantity 场景

如果不从故事文件中删除/删除任何内容,我怎么可能做到这一点。

【问题讨论】:

  • 阅读 JBehave 网站上高级下的元过滤部分。如果我自己理解它,我会解释它,但它几乎描述了你想要完成的事情。 JBehave Meta Filtering

标签: automation jbehave serenity-bdd jbehave-maven-plugin


【解决方案1】:

BDD 风格的场景是完全独立的。在这种情况下,您将有两种情况:

Scenario: I can check out with an updated order quantity
Given I login
And I search
And I add to the cart
And I update the quantity
When I checkout
Then I get a confirmation email (or whatever)

Scenario: I can purchase items
Given I login
And I search
And I add to the cart
And I update the quantity
When I checkout
Then I get a confirmation email (or whatever)

如果担心每个步骤实际上是几个步骤,并且在有 20 个给定的场景中看起来真的很难看,那么只要单独测试每个动作,您就可以使用复合步骤。这是一个在其定义中调用其他步骤的步骤(通过代码,而不是 Gherkin)。你采取同样的行动,但小黄瓜的条目要少得多。

重要的是,任何场景都不应需要 BDD 中先前场景的操作。

为了进一步澄清,如果您确实必须重新排序,有一种方法可以重新排序,但这是非常糟糕的做法。如果你选择走那条路,请看这个问题:

How do i execute story files in specific order in serenity BDD Jbehave

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-31
    • 2011-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多