Class: Xcode::Test::Report
- Inherits:
-
Object
- Object
- Xcode::Test::Report
show all
- Defined in:
- lib/xcode/test/report.rb,
lib/xcode/test/report/test_result.rb,
lib/xcode/test/report/suite_result.rb
Overview
The report is the abstract representation of a collection of suites of tests. Formatters can be attached to write output in real time
Defined Under Namespace
Classes: InvalidStateException, SuiteResult, TestResult
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize {|_self| ... } ⇒ Report
Returns a new instance of Report.
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/xcode/test/report.rb', line 20
def initialize
@exit_code = 0
@suites = []
@formatters = []
@start_time = nil
@end_time = nil
@unexpected = false
@observers = []
yield self if block_given?
end
|
Instance Attribute Details
#end_time ⇒ Object
Returns the value of attribute end_time.
15
16
17
|
# File 'lib/xcode/test/report.rb', line 15
def end_time
@end_time
end
|
#exit_code ⇒ Object
Returns the value of attribute exit_code.
15
16
17
|
# File 'lib/xcode/test/report.rb', line 15
def exit_code
@exit_code
end
|
#observers ⇒ Object
Returns the value of attribute observers.
14
15
16
|
# File 'lib/xcode/test/report.rb', line 14
def observers
@observers
end
|
#start_time ⇒ Object
Returns the value of attribute start_time.
15
16
17
|
# File 'lib/xcode/test/report.rb', line 15
def start_time
@start_time
end
|
#suites ⇒ Object
Returns the value of attribute suites.
14
15
16
|
# File 'lib/xcode/test/report.rb', line 14
def suites
@suites
end
|
#unexpected ⇒ Object
Returns the value of attribute unexpected.
15
16
17
|
# File 'lib/xcode/test/report.rb', line 15
def unexpected
@unexpected
end
|
Instance Method Details
#abort ⇒ Object
107
108
109
110
|
# File 'lib/xcode/test/report.rb', line 107
def abort
@report.unexpected=true
finish
end
|
32
33
34
35
36
|
# File 'lib/xcode/test/report.rb', line 32
def add_formatter(format, *args)
require "xcode/test/formatters/#{format.to_s}_formatter"
formatter = Xcode::Test::Formatters.const_get("#{format.to_s.capitalize}Formatter").new(*args)
@observers << formatter
end
|
#add_suite(name, time = Time.now) ⇒ Object
63
64
65
66
|
# File 'lib/xcode/test/report.rb', line 63
def add_suite(name, time=Time.now)
suite = Xcode::Test::Report::SuiteResult.new(self, name, time)
@suites << suite
end
|
#duration ⇒ Object
72
73
74
75
76
|
# File 'lib/xcode/test/report.rb', line 72
def duration
return 0 if @start_time.nil?
return Time.now - @start_time if @end_time.nil?
@end_time - @start_time
end
|
#failed? ⇒ Boolean
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/xcode/test/report.rb', line 46
def failed?
return true if unexpected?
@suites.each do |suite|
suite.tests.each do |test|
return true if test.failed?
end
end
false
end
|
#finish ⇒ Object
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/xcode/test/report.rb', line 92
def finish
return if finished?
in_current_suite do |suite|
unless suite.finished?
@unexpected = true
suite.finish
end
end
@end_time = Time.now
notify_observers :after, self
end
|
#finished? ⇒ Boolean
68
69
70
|
# File 'lib/xcode/test/report.rb', line 68
def finished?
!@end_time.nil?
end
|
#in_current_suite {|@suites.last| ... } ⇒ Object
78
79
80
81
82
|
# File 'lib/xcode/test/report.rb', line 78
def in_current_suite
return if @suites.size==0 or !@suites.last.end_time.nil?
yield @suites.last
end
|
#in_current_test ⇒ Object
84
85
86
87
88
89
90
|
# File 'lib/xcode/test/report.rb', line 84
def in_current_test
in_current_suite do |suite|
return if suite.tests.size==0
yield suite.tests.last
end
end
|
#notify_observers(event, obj = nil) ⇒ Object
112
113
114
115
116
|
# File 'lib/xcode/test/report.rb', line 112
def notify_observers(event, obj=nil)
@observers.each do |f|
f.send event, obj if f.respond_to? event
end
end
|
#start ⇒ Object
58
59
60
61
|
# File 'lib/xcode/test/report.rb', line 58
def start
@start_time = Time.now
notify_observers :before, self
end
|
#succeed? ⇒ Boolean
42
43
44
|
# File 'lib/xcode/test/report.rb', line 42
def succeed?
!self.failed?
end
|
#unexpected? ⇒ Boolean
38
39
40
|
# File 'lib/xcode/test/report.rb', line 38
def unexpected?
@unexpected
end
|