Class: Semaphore::CucumberBooster
- Inherits:
-
Object
- Object
- Semaphore::CucumberBooster
- Defined in:
- lib/test_boosters/cucumber_booster.rb
Instance Method Summary collapse
-
#initialize(thread_index) ⇒ CucumberBooster
constructor
A new instance of CucumberBooster.
- #run ⇒ Object
- #run_command(specs) ⇒ Object
- #select ⇒ Object
- #with_fallback ⇒ Object
Constructor Details
#initialize(thread_index) ⇒ CucumberBooster
Returns a new instance of CucumberBooster.
10 11 12 13 14 |
# File 'lib/test_boosters/cucumber_booster.rb', line 10 def initialize(thread_index) @thread_index = thread_index @cucumber_split_configuration_path = ENV["CUCUMBER_SPLIT_CONFIGURATION_PATH"] || "#{ENV["HOME"]}/cucumber_split_configuration.json" @spec_path = ENV["SPEC_PATH"] || "features" end |
Instance Method Details
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/test_boosters/cucumber_booster.rb', line 16 def run exit_code = true begin features_to_run = select if features_to_run.empty? puts "No feature files in this thread!" else exit_code = run_command(features_to_run.join(" ")) end rescue StandardError => e if @thread_index == 0 exit_code = run_command(@spec_path) end end exit_code end |
#run_command(specs) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/test_boosters/cucumber_booster.rb', line 34 def run_command(specs) puts puts "========================= Running Cucumber ==========================" puts Semaphore::execute("bundle exec cucumber #{specs}") end |
#select ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/test_boosters/cucumber_booster.rb', line 42 def select with_fallback do file_distribution = JSON.parse(File.read(@cucumber_split_configuration_path)) thread_count = file_distribution.count thread = file_distribution[@thread_index] all_features = Dir["#{@spec_path}/**/*.feature"].sort all_known_features = file_distribution.map { |t| t["files"] }.flatten.sort all_leftover_features = all_features - all_known_features thread_leftover_features = LeftoverFiles.select(all_leftover_features, thread_count, @thread_index) thread_features = all_features & thread["files"].sort features_to_run = thread_features + thread_leftover_features Semaphore.display_files("This thread features:", thread_features) Semaphore.display_title_and_count("All leftover features:", all_leftover_features) Semaphore.display_files("This thread leftover features:", thread_leftover_features) features_to_run end end |
#with_fallback ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/test_boosters/cucumber_booster.rb', line 64 def with_fallback yield rescue StandardError => e error = %{ WARNING: An error detected while parsing the test boosters report file. WARNING: All tests will be executed on the first thread. } puts error error += %{Exception: #{e.}} Semaphore.log(error) raise end |