How to ignore particular scenario in cucumber?

selvi picture selvi · Jan 7, 2016 · Viewed 65k times · Source
  1. I am using cucumber to feed scenario and java as a language.
  2. I need to ignore particular scenario, while running an automation test.
  3. I have tried with below @ignore syntax, it doesn't work at all.
  4. It doesn't skip particular scenario, it keeps on executing all the test scenario, which I have feed in the feature file.

Feature File

@ActivateSegment
Feature: Test for Activate segment

  Scenario: Login
    Given I navigate to M
    And I enter user name 
    And I enter password 
    And I login to MM

  Scenario: Open grid
    Given I choose menu
    And I choose Segments menu

  Scenario: Open segment creation page
    Given I click on New button
    And I click on Segment button

Answer

Aravin picture Aravin · Jan 7, 2016

Use tag ~@tag_name

To exclude scenarios with a certain tag

cucumber --tags ~@tag_name

Note I used ~ symbol.


One thing to note here is that Cucumber will exit with a status of 1 if your @wip-tagged scenarios pass (it’s a reminder that they’re not works in progress anymore since they pass).

UPDATE 1

Sample Scenario

@billing
Feature: Verify billing

  @important
  Scenario: Missing product description

  Scenario: Several products

Running Tags

cucumber --tags @billing            # Runs both scenarios
cucumber --tags @important          # Runs the first scenario
cucumber --tags ~@important         # Runs the second scenario (Scenarios without @important)

Offical document: https://github.com/cucumber/cucumber/wiki/Tags