How to exclude files/directories when running a Cucumber Rake task?

1.7k Views Asked by At

I currently have two folders with different features within my scenarios folder:

features
  scenarios
    folder_1
      first_feature.feature
    folder_2
      second_feature.feature

Inside these features I have many scenarios that share some different tags

first_feature.feature:

Feature: One
  @tag1 @tag2
  Scenario: Scenario 1

  @tag3
  Scenario: Scenario 2

second_feature.feature:

Feature: Two
  @tag1 @tag4
  Scenario: Scenario 3

So here's the question: I have a rake task which goes through my scenarios and runs everything with the tag @tag1. Right now that includes Scenario 1 in feature one and Sceanrio 3 in Feature 2. Without changing any tags or scenarios, is there anything I can add to my rake task to tell it to ignore any tests in a certain file/folder? In the example above, I would like my rake task to ignore any scenarios it finds in folder_2, so Scenario 3 will not run even though it has @tag1.

My current rake task:

Cucumber::Rake::Task.new(:all_tag_1) do |t|
  tags = '--tags ~@wip --tags @tag1'
  t.cucumber_opts = "--format html --out features/build_results/all_tag_1.html --format pretty #{tags} --format junit --out features/build_results/reports"
end

Part of the problem is that I have scoured the internet and Cucumber documentation and am unable to find anywhere that lists all of the valid options for cucumber_opts. If anyone can even just point me in the right direction to find a list of the different possibilities, that would be much appreciated.

Thank you.

1

There are 1 best solutions below

3
On BEST ANSWER

Cucumber::Rake::Task.new(:all_tag_1) do |t| tags = '--tags ~@wip --tags @tag1' t.cucumber_opts = "features/scenarios/folder_1 --format html --out features/build_results/all_tag_1.html --format pretty #{tags} --format junit --out features/build_results/reports" end

This command will only run scenarios from features/scenarios/folder_1 folder...