Class: ParallelTests::Cucumber::Runner
Class Method Summary
collapse
execute_command, find_results, test_env_number
Class Method Details
.cucumber_opts(given) ⇒ Object
65
66
67
68
69
70
71
|
# File 'lib/parallel_tests/cucumber/runner.rb', line 65
def self.cucumber_opts(given)
if given =~ /--profile/ or given =~ /(^|\s)-p /
given
else
[given, profile_from_config].compact.join(" ")
end
end
|
.executable ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'lib/parallel_tests/cucumber/runner.rb', line 19
def self.executable
if ParallelTests.bundler_enabled?
"bundle exec cucumber"
elsif File.file?("script/cucumber")
"script/cucumber"
else
"cucumber"
end
end
|
.line_is_result?(line) ⇒ Boolean
41
42
43
|
# File 'lib/parallel_tests/cucumber/runner.rb', line 41
def self.line_is_result?(line)
line =~ /^\d+ (steps?|scenarios?)/
end
|
.profile_from_config ⇒ Object
73
74
75
76
77
78
79
|
# File 'lib/parallel_tests/cucumber/runner.rb', line 73
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, options) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/parallel_tests/cucumber/runner.rb', line 6
def self.run_tests(test_files, process_number, options)
color = ($stdout.tty? ? 'AUTOTEST=1 ; export AUTOTEST ;' : '') runtime_logging = " --format ParallelTests::Cucumber::RuntimeLogger --out #{runtime_log}"
cmd = [
color,
executable,
(runtime_logging if File.directory?(File.dirname(runtime_log))),
cucumber_opts(options[:test_options]),
*test_files
].compact.join(" ")
execute_command(cmd, process_number, options)
end
|
.runtime_log ⇒ Object
29
30
31
|
# File 'lib/parallel_tests/cucumber/runner.rb', line 29
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)
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/parallel_tests/cucumber/runner.rb', line 48
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
33
34
35
|
# File 'lib/parallel_tests/cucumber/runner.rb', line 33
def self.test_file_name
"feature"
end
|
.test_suffix ⇒ Object
37
38
39
|
# File 'lib/parallel_tests/cucumber/runner.rb', line 37
def self.test_suffix
".feature"
end
|
.tests_in_groups(tests, num_groups, options = {}) ⇒ Object
81
82
83
84
85
86
87
|
# File 'lib/parallel_tests/cucumber/runner.rb', line 81
def self.tests_in_groups(tests, num_groups, options={})
if options[:group_by] == :steps
Grouper.by_steps(find_tests(tests, options), num_groups)
else
super
end
end
|