3
4
5
6
7
8
9
10
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/easytest/runner.rb', line 3
def run
include_only_case = cases.any?(&:only?)
hooks_by_file = hooks.group_by(&:file)
cases.group_by(&:file).each do |file, cases_per_file|
self.file_count += 1
hooks = hooks_by_file.fetch(file, [])
before_hooks = hooks.filter(&:before?)
after_hooks = hooks.filter(&:after?)
reports = []
cases_per_file.each do |c|
if include_only_case && !c.only?
c.skip!
end
result, report =
begin
before_hooks.each { |hook| hook.run(c) }
c.run
ensure
after_hooks.each { |hook| hook.run(c) }
end
case result
when :passed
self.passed_count += 1
when :failed
self.failed_count += 1
when :skipped
self.skipped_count += 1
when :todo
self.todo_count += 1
else
raise "Unknown result: #{result.inspect}"
end
reports << [result, report] if report
end
link = Utils.terminal_hyperlink(file)
if reports.none? { |result, _| result == :failed }
puts "#{Rainbow(" PASS ").bright.bg(:green)} #{link}"
else
puts "#{Rainbow(" FAIL ").bright.bg(:red)} #{link}"
end
print_reports(reports)
end
if no_tests?
print_error_for_no_tests if no_tests_forbidden?
false
else
puts ""
puts "#{Rainbow('Tests:').bright} #{summary}"
puts "#{Rainbow('Time:').bright} #{elapsed_time.round(5)} seconds"
all_passed?
end
end
|