Home > OS >  or condition not working with cucumber tags
or condition not working with cucumber tags

Time:11-17

I am working on cucumber(4.1.0), ruby(2.3.3) and Rakefile. I have one basic feature to test how tags are working. Following is the Feature having 3 different scenerio.

Feature: Test::Unit
  In order to please people who like Test::Unit
  As a Cucumber user
  I want to be able to use assert* in my step definitions
  

 @smoke
  Scenario: assert_equal
    Given x = 5
    And y = 5
    Then I can assert that x == y
    
  @online
  Scenario: assert_equal
    Given x = 6
    And y = 6
    Then I can assert that x == y
    
  @smoke @online
  Scenario: assert_equal
    Given x = 7
    And y = 7
    Then I can assert that x == y

and following is the Rakefile having three tasks.

require 'cucumber/rake/task'
namespace :cucumber do
    Cucumber::Rake::Task.new("smoke") do |t|
      tags = "--tags @smoke"
      t.cucumber_opts = "#{tags} -p online"
    end
    
    Cucumber::Rake::Task.new("online") do |t|
      tags = "--tags @online"
      t.cucumber_opts = "#{tags} -p online"
    end
    
    Cucumber::Rake::Task.new("smokeonline") do |t|
      tags = "--tags @smoke or @online"
      t.cucumber_opts = "#{tags}"
    end
end

In this file 2 profiles are working fine. rake cucumber:smoke rake cucumber:online

but third profile rake cucumber:smokeonline not working which has or condition with tags and prints following message on console. I was expecting because of this or condition all three scenerio should be exected.

What I am missing here?

enter image description here

CodePudding user response:

According to the Docs You can only omit quotes if the expression is a single tag

Running a subset of scenarios

You can tell Cucumber to only run scenarios with a particular tag:

# You can omit the quotes if the expression is a single tag
cucumber --tags "@smoke and @fast"

So all you need to do is change

"--tags @smoke or @online"

To:

'--tags "@smoke or @online"'
  • Related