Lominskiy Volodimyr
Lominskiy Volodimyr

Reputation: 91

How to ignore particular example in cucumber

As a test automation engineer. I'd like to exclude some examples in runtime. For example:

Scenario: Some simple scenario
 Given I logged in as <local> user
 When  I visit home page
 Then  I should see <local> logo

Examples: User
 |local|
 |UK   |
#ignore 'Spain'
 |Spain|

Upvotes: 2

Views: 3410

Answers (2)

diabolist
diabolist

Reputation: 4099

its possible to run just one example from the outline by using the line number, so if your UK example was on line 8 of simple.feature you could run

cucumber features/simple.feature:8

There is no way to run a bunch of features and exclude a particular scenario without tagging or modifying the feature file as far as I'm aware. Run cucumber --help to get full details. Personally I can't understand why you would want to do this, perhaps you could explain why you want to do this and give an example, there might be alternative workflows that would work for you.

Upvotes: 2

Tom Lord
Tom Lord

Reputation: 28305

A possible approach I'd suggest is to use tags:

Scenario Outline: Some simple scenario
  Given I logged in as <local> user
  When  I visit home page
  Then  I should see <local> logo

  Examples:
    | local |
    | UK    |

  @wip
  Examples:
    | local |
    | Spain |

This will, by default, skip the "work in progress" tests. There are also other approaches you could take, to run the tests as "expected failures".

Upvotes: 2

Related Questions