How do I run a specific Behat scenario

Viewed 22567

I'm trying to run a specific Behat scenario from the command line, here's what I'm doing:

$ bin/behat features/features/baseline.feature:3

However this isn't picking up the scenario.

If I run

bin/behat features/features/baseline.feature

I can get the entire feature file to run.

Here's what the file looks like -- the scenario I'm trying to run is on line 3 in my text editor:

Feature:
  @api
  Scenario: Clear cache
    Given the cache has been cleared
    When I am on the homepage
    Then I should get a "200" HTTP response

  Scenario:
    Given I am not logged in
    When I am on the homepage
    Then I should see the text "We love our users"
3 Answers

Found out you can simply tag a scenario with any custom tag, for example @foobar.

Feature:
  @api @foobar
  Scenario: Clear cache
    Given the cache has been cleared
    When I am on the homepage
    Then I should get a "200" HTTP response

  Scenario:
    Given I am not logged in
    When I am on the homepage
    Then I should see the text "We love our users"

And then have only this scenarios run with:

behat --tags foobar

I find that I have to use the full path to the feature file only when executing a specific scenario. For example, if your feature file was in /var/www/html/tests/features/features, and your in /var/www/html/tests then try this command:

bin/behat /var/www/html/tests/features/features/baseline.feature:3
Related