Class: Gurke::Reporters::DefaultReporter
Overview
The DefaultReporter prints features, scenarios and steps while they are executed.
That includes colorized step results reports etc.
Constant Summary
Gurke::Reporter::CALLBACKS
Instance Attribute Summary collapse
Instance Method Summary
collapse
#before_features, #end_feature, #end_features, #end_scenario, #end_step, #start_feature, #start_features, #start_scenario, #start_step
Constructor Details
Returns a new instance of DefaultReporter.
19
20
21
22
|
# File 'lib/gurke/reporters/default_reporter.rb', line 19
def initialize(io = $stdout)
super()
@io = io
end
|
Instance Attribute Details
#io ⇒ Object
Returns the value of attribute io.
17
18
19
|
# File 'lib/gurke/reporters/default_reporter.rb', line 17
def io
@io
end
|
Instance Method Details
#after_feature ⇒ Object
89
90
91
|
# File 'lib/gurke/reporters/default_reporter.rb', line 89
def after_feature(*)
io.puts
end
|
#after_features(features) ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/gurke/reporters/default_reporter.rb', line 93
def after_features(features)
scenarios = features.map(&:scenarios).flatten
size = scenarios.size
passed = scenarios.count(&:passed?)
failed = scenarios.count(&:failed?)
pending = scenarios.count(&:pending?)
not_run = size - scenarios.count(&:run?)
message = "#{scenarios.size} scenarios: "
message += "#{passed} passed, " unless passed == size || passed.zero?
message += "#{failed} failing, #{pending} pending"
message += ", #{not_run} not run" if not_run.positive?
if failed.positive?
io.puts red message
elsif pending.positive? || not_run.positive?
io.puts yellow message
else
io.puts green message
end
io.puts
end
|
#after_scenario ⇒ Object
85
86
87
|
# File 'lib/gurke/reporters/default_reporter.rb', line 85
def after_scenario(*)
io.puts
end
|
#after_step(step, *args) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/gurke/reporters/default_reporter.rb', line 65
def after_step(step, *args)
case step.state
when :pending then step_pending(step, *args)
when :failed then step_failed(step, *args)
when :passed then step_passed(step, *args)
else step_skipped(step, *args)
end
io.puts
io.flush
end
|
#before_feature(feature) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/gurke/reporters/default_reporter.rb', line 24
def before_feature(feature)
io.print yellow('Feature')
io.print ': '
io.print feature.name
io.print ' '
io.print format_location(feature)
io.puts
io.print light_black(feature.description.gsub(/^/, ' '))
io.puts
io.puts
end
|
#before_scenario(scenario) ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'lib/gurke/reporters/default_reporter.rb', line 37
def before_scenario(scenario)
io.print ' '
io.print yellow('Scenario')
io.print ': '
io.print scenario.name
io.print ' '
io.print format_location(scenario)
io.puts
end
|
#before_step(step) ⇒ Object
57
58
59
60
61
62
63
|
# File 'lib/gurke/reporters/default_reporter.rb', line 57
def before_step(step, *)
io.print ' ' if @background
io.print ' '
io.print yellow(step.keyword)
io.print ' '
io.print step.name.gsub(/"(.*?)"/, cyan('\0'))
end
|
#end_background ⇒ Object
53
54
55
|
# File 'lib/gurke/reporters/default_reporter.rb', line 53
def end_background(*)
@background = false
end
|
#retry_scenario(scenario) ⇒ Object
77
78
79
80
81
82
83
|
# File 'lib/gurke/reporters/default_reporter.rb', line 77
def retry_scenario(scenario)
if scenario.flaky?
io.print "\n Retry flaky scenario due to previous failure:\n\n"
else
io.print "\n Retry scenario due to previous failure:\n\n"
end
end
|
#start_background ⇒ Object
47
48
49
50
51
|
# File 'lib/gurke/reporters/default_reporter.rb', line 47
def start_background(*)
io.puts light_black(' Background:') unless @background
@background = true
end
|