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
31
|
# File 'lib/xcode/test/report.rb', line 20
def initialize
@debug = false
@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
108
109
110
111
|
# File 'lib/xcode/test/report.rb', line 108
def abort
@report.unexpected=true
finish
end
|
33
34
35
36
37
|
# File 'lib/xcode/test/report.rb', line 33
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
64
65
66
67
|
# File 'lib/xcode/test/report.rb', line 64
def add_suite(name, time=Time.now)
suite = Xcode::Test::Report::SuiteResult.new(self, name, time)
@suites << suite
end
|
#duration ⇒ Object
73
74
75
76
77
|
# File 'lib/xcode/test/report.rb', line 73
def duration
return 0 if @start_time.nil?
return Time.now - @start_time if @end_time.nil?
@end_time - @start_time
end
|
#failed? ⇒ Boolean
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/xcode/test/report.rb', line 47
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/xcode/test/report.rb', line 93
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
69
70
71
|
# File 'lib/xcode/test/report.rb', line 69
def finished?
!@end_time.nil?
end
|
#in_current_suite {|@suites.last| ... } ⇒ Object
79
80
81
82
83
|
# File 'lib/xcode/test/report.rb', line 79
def in_current_suite
return if @suites.size==0 or !@suites.last.end_time.nil?
yield @suites.last
end
|
#in_current_test ⇒ Object
85
86
87
88
89
90
91
|
# File 'lib/xcode/test/report.rb', line 85
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
113
114
115
116
117
|
# File 'lib/xcode/test/report.rb', line 113
def notify_observers(event, obj=nil)
@observers.each do |f|
f.send event, obj if f.respond_to? event
end
end
|
#start ⇒ Object
59
60
61
62
|
# File 'lib/xcode/test/report.rb', line 59
def start
@start_time = Time.now
notify_observers :before, self
end
|
#succeed? ⇒ Boolean
43
44
45
|
# File 'lib/xcode/test/report.rb', line 43
def succeed?
!self.failed?
end
|
#unexpected? ⇒ Boolean
39
40
41
|
# File 'lib/xcode/test/report.rb', line 39
def unexpected?
@unexpected
end
|