Search code examples
behat

It is possible to exclude a tag with Behat?


I know the way to run only the tests tagged with a chosen @tag:

@invite
Feature: As User I want to invite a friend to join on MySocial

  @mytag
  Scenario: Exists a Facebook user
    Given I go to "/"
    When I follow "Invite a friend"
    ...

Is is possible to do exactly the opposite?


Solution

  • Yes, it is possible to exclude a tag or a list of tags from the command line:

    behat --tags '~@javascript'
    

    It is also possible to set excluded (and included) tags in a profile in behat.yml.

    Behat 2.x

    default:
      filters:
        tags: "~@wip&&~@postponed&&~@disabled"
    

    In the example above I exclude anything that's taged @wip (work in progress), @postponed or @disabled.

    Behat 3.x

    In Behat 3, you can not only configure tags for profiles, but also for suites. The syntax is a bit different:

    default:
        gherkin:
            filters:
                tags: "~@wip&&~@disabled"
    
    suites:
        admin:
            filters:
                tags: "@admin"
    

    Related docs