From 4d31733d0052247fc908dc6dff10e2a31424438c Mon Sep 17 00:00:00 2001 From: Matthew Rooth Date: Sun, 17 Jul 2016 11:43:26 +0100 Subject: [PATCH] added empty steps to each of the test data feature files to work around outstanding cucumber issue: https://github.com/cucumber/cucumber-ruby/issues/967; fixed scenario grouping tests --- Gemfile | 3 +- spec/lib/parallel_calabash/adb_helper_spec.rb | 1 - .../parallel_calabash/feature_grouper_spec.rb | 54 ++++++++++++------- spec/test_data/features/aaa.feature | 16 +++++- spec/test_data/features/bbb.feature | 8 ++- spec/test_data/features/ccc.feature | 7 ++- spec/test_data/features/ddd.feature | 5 +- spec/test_data/features/eee.feature | 4 +- 8 files changed, 70 insertions(+), 28 deletions(-) diff --git a/Gemfile b/Gemfile index caa0351..7dcee43 100644 --- a/Gemfile +++ b/Gemfile @@ -5,4 +5,5 @@ gemspec gem 'rake' gem 'calabash-android' gem 'pry' -gem 'rspec' \ No newline at end of file +gem 'rspec' +gem 'minitest', '~> 4.7.5' \ No newline at end of file diff --git a/spec/lib/parallel_calabash/adb_helper_spec.rb b/spec/lib/parallel_calabash/adb_helper_spec.rb index 0b05fca..eb09016 100644 --- a/spec/lib/parallel_calabash/adb_helper_spec.rb +++ b/spec/lib/parallel_calabash/adb_helper_spec.rb @@ -1,5 +1,4 @@ require 'spec_helper' -require 'minitest/mock' require 'parallel_calabash/adb_helper' describe ParallelCalabash::AdbHelper do diff --git a/spec/lib/parallel_calabash/feature_grouper_spec.rb b/spec/lib/parallel_calabash/feature_grouper_spec.rb index 97ba2ae..e29ca75 100644 --- a/spec/lib/parallel_calabash/feature_grouper_spec.rb +++ b/spec/lib/parallel_calabash/feature_grouper_spec.rb @@ -19,37 +19,37 @@ describe :feature_groups do it 'should group all features in only one group' do - expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>nil}, 1)).to eq \ + expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder => ['spec/test_data/features'], :concurrent => nil}, 1)).to eq \ [["spec/test_data/features/aaa.feature", "spec/test_data/features/bbb.feature", "spec/test_data/features/ccc.feature", "spec/test_data/features/ddd.feature", "spec/test_data/features/eee.feature", "spec/test_data/features/fff.feature"]] end it 'should divide features in 2 groups' do - expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>nil}, 2)).to eq \ + expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder => ['spec/test_data/features'], :concurrent => nil}, 2)).to eq \ [["spec/test_data/features/aaa.feature", "spec/test_data/features/bbb.feature", "spec/test_data/features/ccc.feature"], ["spec/test_data/features/ddd.feature", "spec/test_data/features/eee.feature", "spec/test_data/features/fff.feature"]] end it 'should divide features in 3 groups' do - expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>nil}, 3)).to eq \ + expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder => ['spec/test_data/features'], :concurrent => nil}, 3)).to eq \ [["spec/test_data/features/aaa.feature", "spec/test_data/features/bbb.feature"], ["spec/test_data/features/ccc.feature", "spec/test_data/features/ddd.feature"], ["spec/test_data/features/eee.feature", "spec/test_data/features/fff.feature"]] end it 'should divide features in 4 groups' do - expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>nil}, 4)).to eq \ + expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder => ['spec/test_data/features'], :concurrent => nil}, 4)).to eq \ [["spec/test_data/features/aaa.feature", "spec/test_data/features/eee.feature"], ["spec/test_data/features/bbb.feature", "spec/test_data/features/fff.feature"], ["spec/test_data/features/ccc.feature"], ["spec/test_data/features/ddd.feature"]] end it 'should divide features in 5 groups' do - expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>nil}, 5)).to eq \ + expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder => ['spec/test_data/features'], :concurrent => nil}, 5)).to eq \ [["spec/test_data/features/aaa.feature", "spec/test_data/features/fff.feature"], ["spec/test_data/features/bbb.feature"], ["spec/test_data/features/ccc.feature"], ["spec/test_data/features/ddd.feature"], ["spec/test_data/features/eee.feature"]] end it 'should create 1 group for concurrent 1 process' do - expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>true}, 1)).to eq \ + expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder => ['spec/test_data/features'], :concurrent => true}, 1)).to eq \ [["spec/test_data/features/aaa.feature", "spec/test_data/features/bbb.feature", "spec/test_data/features/ccc.feature", "spec/test_data/features/ddd.feature", "spec/test_data/features/eee.feature", "spec/test_data/features/fff.feature"]] end it 'should create 2 group for concurrent 2 processes' do - expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder =>['spec/test_data/features'],:concurrent=>true}, 2)).to eq \ + expect(ParallelCalabash::FeatureGrouper.feature_groups({:feature_folder => ['spec/test_data/features'], :concurrent => true}, 2)).to eq \ [["spec/test_data/features/aaa.feature", "spec/test_data/features/bbb.feature", "spec/test_data/features/ccc.feature", "spec/test_data/features/ddd.feature", "spec/test_data/features/eee.feature", "spec/test_data/features/fff.feature"], ["spec/test_data/features/aaa.feature", "spec/test_data/features/bbb.feature", "spec/test_data/features/ccc.feature", "spec/test_data/features/ddd.feature", "spec/test_data/features/eee.feature", "spec/test_data/features/fff.feature"]] end @@ -108,21 +108,35 @@ describe :scenario_groups do it 'should groups all @runnable scenario equally into 2 groups' do - expect(ParallelCalabash::FeatureGrouper.scenario_groups(2,{:feature_folder => ["spec/test_data/features"],:cucumber_options => "--tags @runnable"})).to eq \ - [["spec/test_data/features/aaa.feature:10", "spec/test_data/features/aaa.feature:16", "spec/test_data/features/aaa.feature:19", "spec/test_data/features/bbb.feature:13"], ["spec/test_data/features/bbb.feature:16", "spec/test_data/features/ccc.feature:11", "spec/test_data/features/ddd.feature:7", "spec/test_data/features/ddd.feature:10"]] - end - - it 'should groups all @runnable scenario equally into 2 groups' do - expect(ParallelCalabash::FeatureGrouper.scenario_groups(3,{:feature_folder => ["spec/test_data/features"],:cucumber_options => "--tags @runnable"})).to eq \ - [["spec/test_data/features/aaa.feature:10", "spec/test_data/features/aaa.feature:16", "spec/test_data/features/ddd.feature:7"], ["spec/test_data/features/aaa.feature:19", "spec/test_data/features/bbb.feature:13", "spec/test_data/features/ddd.feature:10"], ["spec/test_data/features/bbb.feature:16", "spec/test_data/features/ccc.feature:11"]] - end - - it 'should groups all @runnable scenario equally into 2 groups' do - expect(ParallelCalabash::FeatureGrouper.scenario_groups(4,{:feature_folder => ["spec/test_data/features"],:cucumber_options => "--tags @runnable"})).to eq \ - [["spec/test_data/features/aaa.feature:10", "spec/test_data/features/aaa.feature:16"], ["spec/test_data/features/aaa.feature:19", "spec/test_data/features/bbb.feature:13"], ["spec/test_data/features/bbb.feature:16", "spec/test_data/features/ccc.feature:11"], ["spec/test_data/features/ddd.feature:7", "spec/test_data/features/ddd.feature:10"]] + expected = [ + ['spec/test_data/features/aaa.feature:12', 'spec/test_data/features/aaa.feature:20', 'spec/test_data/features/aaa.feature:24', 'spec/test_data/features/bbb.feature:16'], + ['spec/test_data/features/bbb.feature:20', 'spec/test_data/features/ccc.feature:12', 'spec/test_data/features/ddd.feature:8', 'spec/test_data/features/ddd.feature:12'] + ] + actual = ParallelCalabash::FeatureGrouper.scenario_groups(2, {:feature_folder => ['spec/test_data/features'], :cucumber_options => '--tags @runnable'}) + expect(actual).to eq(expected) + end + + it 'should groups all @runnable scenario equally into 3 groups' do + expected = [ + ['spec/test_data/features/aaa.feature:12', 'spec/test_data/features/aaa.feature:20', 'spec/test_data/features/ddd.feature:8'], + ['spec/test_data/features/aaa.feature:24', 'spec/test_data/features/bbb.feature:16', 'spec/test_data/features/ddd.feature:12'], + ['spec/test_data/features/bbb.feature:20', 'spec/test_data/features/ccc.feature:12'] + ] + actual = ParallelCalabash::FeatureGrouper.scenario_groups(3, {:feature_folder => ['spec/test_data/features'], :cucumber_options => '--tags @runnable'}) + expect(actual).to eq(expected) + end + + it 'should groups all @runnable scenario equally into 4 groups' do + actual = ParallelCalabash::FeatureGrouper.scenario_groups(4, {:feature_folder => ['spec/test_data/features'], :cucumber_options => '--tags @runnable'}) + expected = [ + ['spec/test_data/features/aaa.feature:12', 'spec/test_data/features/aaa.feature:20'], + ['spec/test_data/features/aaa.feature:24', 'spec/test_data/features/bbb.feature:16'], + ['spec/test_data/features/bbb.feature:20', 'spec/test_data/features/ccc.feature:12'], + ['spec/test_data/features/ddd.feature:8', 'spec/test_data/features/ddd.feature:12'] + ] + expect(actual).to eq(expected) end end - end diff --git a/spec/test_data/features/aaa.feature b/spec/test_data/features/aaa.feature index 198dc0f..abccc8c 100644 --- a/spec/test_data/features/aaa.feature +++ b/spec/test_data/features/aaa.feature @@ -2,42 +2,56 @@ Feature: aaa feature @tag1 Scenario: + Given empty step @tag1 Scenario: + Given empty step @tag1 @runnable Scenario: + Given empty step @tag1 Scenario: + Given empty step @tag1 @runnable Scenario: + Given empty step @tag1 @runnable Scenario: + Given empty step @tag1 Scenario: + Given empty step @tag1 Scenario: + Given empty step @tag1 Scenario: + Given empty step @tag1 Scenario: + Given empty step @tag1 Scenario: + Given empty step @tag1 Scenario: + Given empty step @tag1 Scenario: + Given empty step @tag1 - Scenario: \ No newline at end of file + Scenario: + Given empty step \ No newline at end of file diff --git a/spec/test_data/features/bbb.feature b/spec/test_data/features/bbb.feature index 98e2527..f86481b 100644 --- a/spec/test_data/features/bbb.feature +++ b/spec/test_data/features/bbb.feature @@ -2,18 +2,24 @@ Feature: bbb.feature @tag1 Scenario: + Given empty step @tag1 Scenario: + Given empty step @tag12 Scenario: + Given empty step @tag1 @runnable Scenario: + Given empty step @tag1 @runnable Scenario: + Given empty step @tag1 - Scenario: \ No newline at end of file + Scenario: + Given empty step \ No newline at end of file diff --git a/spec/test_data/features/ccc.feature b/spec/test_data/features/ccc.feature index 25c3a2e..64a9c5e 100644 --- a/spec/test_data/features/ccc.feature +++ b/spec/test_data/features/ccc.feature @@ -1,14 +1,17 @@ Feature: ccc.feature - @tag1 Scenario: + Given empty step @tag1 Scenario: + Given empty step @tag1 @runnable Scenario: + Given empty step @tag1 - Scenario: \ No newline at end of file + Scenario: + Given empty step \ No newline at end of file diff --git a/spec/test_data/features/ddd.feature b/spec/test_data/features/ddd.feature index 7c90f41..abaa768 100644 --- a/spec/test_data/features/ddd.feature +++ b/spec/test_data/features/ddd.feature @@ -2,9 +2,12 @@ Feature: ddd.feature @tag1 Scenario: + Given empty step @tag1 @runnable Scenario: + Given empty step @tag1 @runnable - Scenario: \ No newline at end of file + Scenario: + Given empty step \ No newline at end of file diff --git a/spec/test_data/features/eee.feature b/spec/test_data/features/eee.feature index 31e9051..13c6277 100644 --- a/spec/test_data/features/eee.feature +++ b/spec/test_data/features/eee.feature @@ -2,6 +2,8 @@ Feature: eee feature @tag1 Scenario: + Given empty step @tag1 - Scenario: \ No newline at end of file + Scenario: + Given empty step \ No newline at end of file