smilyface
smilyface

Reputation: 5531

Ignore particular tag in cucumber but run all other tags

I have a scenario, where I need to run multiple tags and need not run another one when a condition occurs. I don't want to run Feature_1 when the browser is IE.

@run_me @do_not_run
Feature 1
    
@Tag1 @Tag2
Scenario: Scenario 1

@run_me
Feature  2
    
@Tag1 @Tag3
Scenario: Scenario 2

Condition:

if(browser == "IE"){
    then execute all @run_me tags but don't execute it when there is @do_not_run
else
    run all @run_me

Current code:

--tags @run_me

What should be the right way to achieve it?

Note: I tried --tags @run_me ~@do_not_runinside the if condition. But not sure it is the correct method or not.

Upvotes: 1

Views: 1624

Answers (1)

Dilip Meghwal
Dilip Meghwal

Reputation: 632

You can follow below approach to execute the tags.

  1. @fast -- Scenarios tagged with @fast
  2. @wip and not @slow -- Scenarios tagged with @wip that aren’t also tagged with @slow
  3. @smoke and @fast -- Scenarios tagged with both @smoke and @fast
  4. @gui or @database --Scenarios tagged with either @gui or @database

Reference Link

Upvotes: 1

Related Questions