Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

It is possible to exclude a tag with Behat?

Tags:

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?

like image 288
sensorario Avatar asked Feb 24 '14 09:02

sensorario


2 Answers

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

  • Behat 2.x:
    • http://behat.readthedocs.org/en/v2.5/guides/6.cli.html#gherkin-filters
    • http://behat.readthedocs.org/en/v2.5/guides/7.config.html#filters
  • Behat 3.x:
    • http://behat.readthedocs.io/en/latest/user_guide/configuration.html#global-filters
    • http://behat.readthedocs.io/en/latest/user_guide/configuration/suites.html#suite-filters
like image 80
Jakub Zalas Avatar answered Sep 18 '22 17:09

Jakub Zalas


If you want to just do one tag like Jakub said :

behat --tags '~@javascript'

if you want to run multiple scenarios with tags like @Done and not @javascript :

behat --tags '@Done&&~@javascript'
like image 23
esl4m Avatar answered Sep 22 '22 17:09

esl4m