Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
483 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Feature: Randomizing Features & Scenarios | ||
In order to ensure my tests aren't dependent | ||
As a developer | ||
I want spinach to randomize features and scenarios (but not steps) | ||
|
||
Scenario: Randomizing the run without specifying a seed | ||
Given I have 2 features with 2 scenarios each | ||
When I randomize the run without specifying a seed | ||
Then The features and scenarios are run | ||
And The runner output shows a seed | ||
|
||
Scenario: Specifying the seed | ||
Given I have 2 features with 2 scenarios each | ||
When I specify the seed for the run | ||
Then The features and scenarios are run in a different order | ||
And The runner output shows the seed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,25 @@ | ||
Feature: Display run summary | ||
As a developer | ||
I want spinach to display a summary of steps statuses | ||
So I can easyly know general features status | ||
So I can easily know general features status | ||
|
||
Scenario: Display run summary at the end of features run | ||
Scenario: Display run summary at the end of features run without randomization | ||
Given I have a feature that has some successful, undefined, failed and error steps | ||
When I run it | ||
|
||
When I run it without randomization | ||
Then I should see a summary with steps status information | ||
And I shouldn't see a randomization seed | ||
|
||
Scenario: Display run summary at the end of features run with randomization | ||
Given I have a feature that has some successful, undefined, failed and error steps | ||
|
||
When I run it with randomization | ||
Then I should see a summary with steps status information | ||
And I should see a randomization seed | ||
|
||
Scenario: Display run summary at the end of features run with a randomization seed | ||
Given I have a feature that has some successful, undefined, failed and error steps | ||
|
||
When I run it with a specific randomization seed | ||
Then I should see a summary with steps status information | ||
And I should see that specific randomization seed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
class Spinach::Features::RandomizingFeaturesScenarios < Spinach::FeatureSteps | ||
include Integration::SpinachRunner | ||
|
||
step 'I have 2 features with 2 scenarios each' do | ||
write_file 'features/success_a.feature', <<-FEATURE | ||
Feature: Success A | ||
Scenario: A1 | ||
Then a1 | ||
Scenario: A2 | ||
Then a2 | ||
FEATURE | ||
|
||
write_file 'features/steps/success_a.rb', <<-STEPS | ||
class Spinach::Features::SuccessA < Spinach::FeatureSteps | ||
step 'a1' do; end | ||
step 'a2' do; end | ||
end | ||
STEPS | ||
|
||
write_file 'features/success_b.feature', <<-FEATURE | ||
Feature: Success B | ||
Scenario: B1 | ||
Then b1 | ||
Scenario: B2 | ||
Then b2 | ||
FEATURE | ||
|
||
write_file 'features/steps/success_b.rb', <<-STEPS | ||
class Spinach::Features::SuccessB < Spinach::FeatureSteps | ||
step 'b1' do; end | ||
step 'b2' do; end | ||
end | ||
STEPS | ||
end | ||
|
||
step 'I randomize the run without specifying a seed' do | ||
run_spinach({append: "--rand"}) | ||
end | ||
|
||
step 'I specify the seed for the run' do | ||
# Reverse order (A2 A1 B2 B1) is the only way I can show that | ||
# scenarios and features are randomized by the seed when the | ||
# example has 2 features each with 2 scenarios. I tried seeds | ||
# until I found one that ordered the test in that order. | ||
@seed = 1 | ||
|
||
run_spinach({append: "--seed #{@seed}"}) | ||
end | ||
|
||
step 'The features and scenarios are run' do | ||
@stdout.must_include("A1") | ||
@stdout.must_include("A2") | ||
@stdout.must_include("B1") | ||
@stdout.must_include("B2") | ||
end | ||
|
||
step 'The features and scenarios are run in a different order' do | ||
@stdout.must_match(/B2.*B1.*A2.*A1/m) | ||
end | ||
|
||
step 'The runner output shows a seed' do | ||
@stdout.must_match(/^Randomized with seed \d*$/) | ||
end | ||
|
||
step 'The runner output shows the seed' do | ||
@stdout.must_match(/^Randomized with seed #{@seed}$/) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require_relative 'orderers/default' | ||
require_relative 'orderers/random' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Spinach | ||
module Orderers | ||
class Default | ||
def initialize(**options); end | ||
|
||
# Appends any necessary report output (by default does nothing). | ||
# | ||
# @param [IO] io | ||
# Output buffer for report. | ||
# | ||
# @api public | ||
def attach_summary(io); end | ||
|
||
# Returns a reordered version of the provided array | ||
# | ||
# @param [Array] items | ||
# Items to order | ||
# | ||
# @api public | ||
def order(items) | ||
items | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'digest' | ||
|
||
module Spinach | ||
module Orderers | ||
class Random | ||
attr_reader :seed | ||
|
||
def initialize(seed:) | ||
@seed = seed.to_s | ||
end | ||
|
||
# Output the randomization seed in the report summary. | ||
# | ||
# @param [IO] io | ||
# Output buffer for report. | ||
# | ||
# @api public | ||
def attach_summary(io) | ||
io.puts("Randomized with seed #{seed}\n\n") | ||
end | ||
|
||
# Returns a reordered version of the provided array | ||
# | ||
# @param [Array] items | ||
# Items to order | ||
# | ||
# @api public | ||
def order(items) | ||
items.sort_by do |item| | ||
Digest::MD5.hexdigest(seed + item.ordering_id) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.