Class: ParallelTests::Cucumber::Runner
Constant Summary
collapse
- NAME =
'Cucumber'
Class Method Summary
collapse
execute_command, execute_command_and_capture_output, find_results, name, test_env_number
Class Method Details
.cucumber_opts(given) ⇒ Object
68
69
70
71
72
73
74
|
# File 'lib/parallel_tests/cucumber/runner.rb', line 68
def self.cucumber_opts(given)
if given =~ /--profile/ or given =~ /(^|\s)-p /
given
else
[given, profile_from_config].compact.join(" ")
end
end
|
.determine_executable ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'lib/parallel_tests/cucumber/runner.rb', line 22
def self.determine_executable
if ParallelTests.bundler_enabled?
"bundle exec cucumber"
elsif File.file?("script/cucumber")
"script/cucumber"
else
"cucumber"
end
end
|
.line_is_result?(line) ⇒ Boolean
44
45
46
|
# File 'lib/parallel_tests/cucumber/runner.rb', line 44
def self.line_is_result?(line)
line =~ /^\d+ (steps?|scenarios?)/
end
|
.profile_from_config ⇒ Object
76
77
78
79
80
81
82
|
# File 'lib/parallel_tests/cucumber/runner.rb', line 76
def self.profile_from_config
config = Dir.glob('{,.config/,config/}cucumber{.yml,.yaml}').first
if config && File.read(config) =~ /^parallel:/
"--profile parallel"
end
end
|
.run_tests(test_files, process_number, num_processes, options) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/parallel_tests/cucumber/runner.rb', line 9
def self.run_tests(test_files, process_number, num_processes, options)
sanitized_test_files = test_files.map { |val| Shellwords.escape(val) }
options = options.merge(:env => {"AUTOTEST" => "1"}) if $stdout.tty? runtime_logging = " --format ParallelTests::Cucumber::RuntimeLogger --out #{runtime_log}"
cmd = [
executable,
(runtime_logging if File.directory?(File.dirname(runtime_log))),
cucumber_opts(options[:test_options]),
*sanitized_test_files
].compact.join(" ")
execute_command(cmd, process_number, num_processes, options)
end
|
.runtime_log ⇒ Object
32
33
34
|
# File 'lib/parallel_tests/cucumber/runner.rb', line 32
def self.runtime_log
'tmp/parallel_runtime_cucumber.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)
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/parallel_tests/cucumber/runner.rb', line 51
def self.summarize_results(results)
sort_order = %w[scenario step failed undefined skipped pending passed]
%w[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 and number != 1
"#{number} #{word}#{plural}"
end
"#{sums[0]} (#{sums[1..-1].join(", ")})"
end.compact.join("\n")
end
|
.test_file_name ⇒ Object
36
37
38
|
# File 'lib/parallel_tests/cucumber/runner.rb', line 36
def self.test_file_name
"feature"
end
|
.test_suffix ⇒ Object
40
41
42
|
# File 'lib/parallel_tests/cucumber/runner.rb', line 40
def self.test_suffix
".feature"
end
|
.tests_in_groups(tests, num_groups, options = {}) ⇒ Object
84
85
86
87
88
89
90
|
# File 'lib/parallel_tests/cucumber/runner.rb', line 84
def self.tests_in_groups(tests, num_groups, options={})
if options[:group_by] == :steps
Grouper.by_steps(find_tests(tests, options), num_groups, options)
else
super
end
end
|