Execute Behat Feature or Scenario using Partial title match

Profile picture for user devraj

If you want to run only part of your suite, or some scenarios, you can also do it using --name filter. You can use name option to match part of Feature or Scenario title.

For Example:

$ behat --name="element of feature"

Here you don't need to specify your complete feature or scenario title. You can give only Only part of the given name or regex. One point to note here that value is case sensitive. Here word Test is different from test.

Consider This feature file:

#language: en
Feature:Test Login Functionality

    Given I am on homepage
    When I follow "Sign in"
    And I wait 3 seconds

  Scenario: Verify user Login
    And I fill in "email" with "goswami.tarun77+1@gmail.com"
    And I fill in "passwd" with "Test1234"
    And I press "SubmitLogin"
    And I wait 10 seconds

  @smoke @regression
  Scenario: Create New user
    And I fill in "email_create" with "test@gmail.com"
    Then I press "SubmitCreate"
    Then I should see "test"

  Scenario: Forgot password
    And I follow "Forgot your password?"

Example 1: Below command will execute Scenario #1 because Scenario #1 contains Verify user.

$ bin/behat --name 'Verify user'

Example 2: Below command will execute scenario #1 and #2 because Scenario #1 and #2 contains user.

$ bin/behat --name 'user'

Example 3: This command will execute Scenario #2 because that scenario ends with user.

$ bin/behat --name '/user$/'

Example 4: Below command will execute complete feature file because feature title consist of Test Login

$ bin/behat --name 'Test Login'

Example 5: This command will execute nothing because value is case sensitive.

$ bin/behat --name 'test Login'