‹‹ Go to homepage

Tagging features in Gherkin and Behat

13 of February, 2014


Syntax is pretty easy. All you have to do is to put any free form text (prepended with @) on top of feature or scenario:

@sprint-1 @appname-123 @subsystem-name
Feature: Customer can add products to wishlist
  In order to remember products I like
  As a store customer
  I want to store products I like in wishlist

  @wip
  Scenario: Add to wishlist
    Given I am on homepage
    And there is "Awesome item" in product list
    When I add "Awesome item" into wishlist
    Then I get notification message confirming addition to wishlist
    And "Awesome item" is persisted into wishlist associated with current session

Having sprint number, task handle and subsystem tags on feature and work in progress on scenario allows combinations of different tags to control which scenarios to run. I’m using behat, so here is how to filter running features and scenarios:

# run all the features from sprint 1
bin/behat --tags="@sprint-1"

# run all the features related to task appname-123
bin/behat --tags="@appname-123"

# run only scenario which I'm working on
bin/behat --tags="@appname-123&&@wip"
comments powered by Disqus