Class: ParallelTests::Gherkin::Runner
- Inherits:
-
Test::Runner
- Object
- Test::Runner
- ParallelTests::Gherkin::Runner
- Defined in:
- lib/parallel_tests/gherkin/runner.rb
Direct Known Subclasses
Class Method Summary collapse
- .build_test_command(file_list, options) ⇒ Object
- .cucumber_opts(given) ⇒ Object
- .default_test_folder ⇒ Object
- .determine_executable ⇒ Object
- .line_is_result?(line) ⇒ Boolean
- .profile_from_config ⇒ Object
- .run_tests(test_files, process_number, num_processes, options) ⇒ Object
- .runtime_log ⇒ Object
- .runtime_logging ⇒ Object
-
.summarize_results(results) ⇒ Object
cucumber has 2 result lines per test run, that cannot be added 1 scenario (1 failed) 1 step (1 failed).
- .test_file_name ⇒ Object
- .test_suffix ⇒ Object
- .tests_in_groups(tests, num_groups, options = {}) ⇒ Object
Class Method Details
.build_test_command(file_list, options) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/parallel_tests/gherkin/runner.rb', line 40 def build_test_command(file_list, ) [ *executable, *(runtime_logging if File.directory?(File.dirname(runtime_log))), *file_list, *cucumber_opts([:test_options]) ] end |
.cucumber_opts(given) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/parallel_tests/gherkin/runner.rb', line 69 def cucumber_opts(given) if given&.include?('--profile') || given&.include?('-p') given else [*given, *profile_from_config] end end |
.default_test_folder ⇒ Object
28 29 30 |
# File 'lib/parallel_tests/gherkin/runner.rb', line 28 def default_test_folder 'features' end |
.determine_executable ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/parallel_tests/gherkin/runner.rb', line 101 def determine_executable if File.exist?("bin/#{name}") ParallelTests.with_ruby_binary("bin/#{name}") elsif ParallelTests.bundler_enabled? ["bundle", "exec", name] elsif File.file?("script/#{name}") ParallelTests.with_ruby_binary("script/#{name}") else [name.to_s] end end |
.line_is_result?(line) ⇒ Boolean
36 37 38 |
# File 'lib/parallel_tests/gherkin/runner.rb', line 36 def line_is_result?(line) line =~ /^\d+ (steps?|scenarios?)/ end |
.profile_from_config ⇒ Object
77 78 79 80 81 |
# File 'lib/parallel_tests/gherkin/runner.rb', line 77 def profile_from_config # copied from https://github.com/cucumber/cucumber/blob/master/lib/cucumber/cli/profile_loader.rb#L85 config = Dir.glob("{,.config/,config/}#{name}{.yml,.yaml}").first ['--profile', 'parallel'] if config && File.read(config) =~ /^parallel:/ end |
.run_tests(test_files, process_number, num_processes, options) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/parallel_tests/gherkin/runner.rb', line 8 def run_tests(test_files, process_number, num_processes, ) combined_scenarios = test_files if [:group_by] == :scenarios grouped = test_files.map { |t| t.split(':') }.group_by(&:first) combined_scenarios = grouped.map do |file, files_and_lines| "#{file}:#{files_and_lines.map(&:last).join(':')}" end end [:env] ||= {} [:env] = [:env].merge({ 'AUTOTEST' => '1' }) if $stdout.tty? execute_command(build_command(combined_scenarios, ), process_number, num_processes, ) end |
.runtime_log ⇒ Object
97 98 99 |
# File 'lib/parallel_tests/gherkin/runner.rb', line 97 def runtime_log "tmp/parallel_runtime_#{name}.log" end |
.runtime_logging ⇒ Object
93 94 95 |
# File 'lib/parallel_tests/gherkin/runner.rb', line 93 def runtime_logging ['--format', 'ParallelTests::Gherkin::RuntimeLogger', '--out', runtime_log] end |
.summarize_results(results) ⇒ Object
cucumber has 2 result lines per test run, that cannot be added 1 scenario (1 failed) 1 step (1 failed)
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/parallel_tests/gherkin/runner.rb', line 52 def summarize_results(results) sort_order = ['scenario', 'step', 'failed', 'flaky', 'undefined', 'skipped', 'pending', 'passed'] ['scenario', 'step'].map do |group| group_results = results.grep(/^\d+ #{group}/) next if group_results.empty? sums = sum_up_results(group_results) sums = sums.sort_by { |word, _| sort_order.index(word) || 999 } sums.map! do |word, number| plural = "s" if (word == group) && (number != 1) "#{number} #{word}#{plural}" end "#{sums[0]} (#{sums[1..].join(", ")})" end.compact.join("\n") end |
.test_file_name ⇒ Object
24 25 26 |
# File 'lib/parallel_tests/gherkin/runner.rb', line 24 def test_file_name @test_file_name || 'feature' end |
.test_suffix ⇒ Object
32 33 34 |
# File 'lib/parallel_tests/gherkin/runner.rb', line 32 def test_suffix /\.feature$/ end |
.tests_in_groups(tests, num_groups, options = {}) ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/parallel_tests/gherkin/runner.rb', line 83 def tests_in_groups(tests, num_groups, = {}) @test_file_name = "scenario" if [:group_by] == :scenarios method = "by_#{[:group_by]}" if Grouper.respond_to?(method) Grouper.send(method, find_tests(tests, ), num_groups, ) else super end end |