Skip to main content
Home
  • Tutorials
    • Quality Assurance
    • Software Development
    • Machine Learning
    • Data Science
  • About Us
  • Contact
programsbuzz facebook programsbuzz twitter programsbuzz linkedin
  • Log in

Main navigation

  • Tutorials
    • Quality Assurance
    • Software Development
    • Machine Learning
    • Data Science
  • About Us
  • Contact

Ignore or Skip Behat Scenario or Feature using Tags

Profile picture for user devraj
Written by devraj on 10/13/2020 - 21:19

You can ignore Behat Tests using tags. ~ symbol is used along with tags to ignore the scenario.

This works both for Scenario as well as Feature. You can skip a scenario, set of scenarios or all scenarios in a feature file. You can also use this with conjunction with AND or OR.

One way of ignoring tag is mention only tags which you want to run in tags value of Behat but this is not best practice. Consider, when out of 10 you have to executed 9 tags and ignore one. Then, there is no benefit of typing 9 tags. In that case we skip tags using ~ operator.

Consider below feature file

#language: en
@login
Feature: Login Functionality

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

  @smoke
  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"

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

Example #1: To execute all scenarios except @smoke.

bin/behat --tags '~@smoke'

This will execute 3rd scenario.

Example #2: Execute Scenario which are are tagged with regression and not with smoke.

bin/behat --tags '@regression&&~smoke'

This will execute nothing.

Example #3: Execute scenarios which are tagged with smoke but not with Regression.

bin/behat --tags '@smoke&&~@regression'

This will executed 1st scenario.

Example #4: Execute Scenario that are either tagged with Sanity or it does not contain @regression tag.

 bin/behat --tags '@sanity,~@regression'

This will execute 1st and 3rd scenarios.

Related Content
Behat Tutorial
Behat Launch Chrome Browser using Mink Selenium2Driver
Install or Update Behat using composer
Tags
Behat
  • Log in or register to post comments

Choose Your Technology

  1. Agile
  2. Apache Groovy
  3. Apache Hadoop
  4. Apache HBase
  5. Apache Spark
  6. Appium
  7. AutoIt
  8. AWS
  9. Behat
  10. Cucumber Java
  11. Cypress
  12. DBMS
  13. Drupal
  14. GitHub
  15. GitLab
  16. GoLang
  17. Gradle
  18. HTML
  19. ISTQB Foundation
  20. Java
  21. JavaScript
  22. JMeter
  23. JUnit
  24. Karate
  25. Kotlin
  26. LoadRunner
  27. matplotlib
  28. MongoDB
  29. MS SQL Server
  30. MySQL
  31. Nightwatch JS
  32. PactumJS
  33. PHP
  34. Playwright
  35. Playwright Java
  36. Playwright Python
  37. Postman
  38. Project Management
  39. Protractor
  40. PyDev
  41. Python
  42. Python NumPy
  43. Python Pandas
  44. Python Seaborn
  45. R Language
  46. REST Assured
  47. Ruby
  48. Selenide
© Copyright By iVagus Services Pvt. Ltd. 2023. All Rights Reserved.

Footer

  • Cookie Policy
  • Privacy Policy
  • Terms of Use