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
- #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 @report_path = ENV["REPORT_PATH"] || "#{ENV["HOME"]}/cucumber_report.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 |
# File 'lib/test_boosters/cucumber_booster.rb', line 16 def run begin features_to_run = select if features_to_run.empty? puts "No feature files in this thread!" else Semaphore::execute("bundle exec cucumber #{features_to_run.join(" ")}") end rescue StandardError => e if @thread_index == 0 Semaphore::execute("bundle exec cucumber #{@spec_path}") end end end |
#select ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/test_boosters/cucumber_booster.rb', line 32 def select with_fallback do feature_report = JSON.parse(File.read(@report_path)) thread_count = feature_report.count thread = feature_report[@thread_index] all_features = Dir["#{@spec_path}/**/*.feature"].sort all_known_features = feature_report.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
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/test_boosters/cucumber_booster.rb', line 54 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.message}} Semaphore::log(error) raise end |