Module: ParallelCucumber

Defined in:
lib/parallel_cucumber.rb,
lib/parallel_cucumber/cli.rb,
lib/parallel_cucumber/runner.rb,
lib/parallel_cucumber/grouper.rb,
lib/parallel_cucumber/version.rb,
lib/parallel_cucumber/result_formatter.rb

Defined Under Namespace

Modules: Cli Classes: Grouper, ResultFormatter, Runner

Constant Summary collapse

VERSION =
'0.1.22'.freeze

Class Method Summary collapse

Class Method Details

.run_tests_in_parallel(options) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/parallel_cucumber.rb', line 11

def run_tests_in_parallel(options)
  number_of_processes = options[:n]
  test_results = nil

  report_time_taken do
    groups = Grouper.feature_groups(options, number_of_processes)
    threads = groups.size
    completed = []

    on_finish = lambda do |_item, index, _result|
      completed.push(index)
      remaining_threads = ((0...threads).to_a - completed).sort
      puts "Thread #{index} has finished. Remaining(#{remaining_threads.count}): #{remaining_threads.join(', ')}"
    end

    test_results = Parallel.map_with_index(
      groups,
      in_threads: threads,
      finish: on_finish
    ) do |group, index|
      Runner.new(options).run_tests(index, group)
    end
    puts 'All threads are complete'
    ResultFormatter.report_results(test_results)
  end
  exit(1) if any_test_failed?(test_results)
end