'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 1:[1]
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:
- Behat 3.x:
Solution 2:[2]
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'
Solution 3:[3]
It skips the scenario and feature but it result in error that no scenario found. It should be passed . Is there any way to pass feature having all skipped scenarios executed through command.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | esl4m |
Solution 3 | Awais Mushtaq |