Class: Test::Reporters::AbstractHash
- Inherits:
-
Abstract
- Object
- Abstract
- Test::Reporters::AbstractHash
show all
- Defined in:
- lib/rubytest/format/abstract_hash.rb
Overview
Hash Abstract is a base class for the TAP-Y and TAP-J reporters.
Direct Known Subclasses
Test
Instance Attribute Summary
Attributes inherited from Abstract
#runner
Instance Method Summary
collapse
Methods inherited from Abstract
inherited, #initialize, registry, #skip_case
Instance Method Details
#begin_case(test_case) ⇒ Hash
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/rubytest/format/abstract_hash.rb', line 37
def begin_case(test_case)
h = {}
h['type' ] = 'case'
h['level'] = @case_level
merge_subtype h, test_case
merge_setup h, test_case
merge_label h, test_case
@case_level += 1
return h
end
|
#begin_suite(suite) ⇒ Hash
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/rubytest/format/abstract_hash.rb', line 13
def begin_suite(suite)
require 'yaml'
require 'stringio'
@start_time = Time.now
@case_level = 0
@test_index = 0
now = Time.now.strftime('%Y-%m-%d %H:%M:%S')
h = {
'type' => 'suite',
'start' => now,
'count' => total_count(suite)
}
h['seed'] = suite.seed if suite.respond_to?(:seed)
return h
end
|
#begin_test(test) ⇒ Object
52
53
54
55
56
57
|
# File 'lib/rubytest/format/abstract_hash.rb', line 52
def begin_test(test)
@test_index += 1
@stdout, @stderr = $stdout, $stderr
$stdout, $stderr = StringIO.new, StringIO.new
end
|
#end_case(test_case) ⇒ Object
176
177
178
|
# File 'lib/rubytest/format/abstract_hash.rb', line 176
def end_case(test_case)
@case_level -= 1
end
|
#end_suite(suite) ⇒ Hash
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
# File 'lib/rubytest/format/abstract_hash.rb', line 183
def end_suite(suite)
h = {
'type' => 'final',
'time' => Time.now - @start_time,
'counts' => {
'total' => total,
'pass' => record[:pass].size,
'fail' => record[:fail].size,
'error' => record[:error].size,
'omit' => record[:omit].size,
'todo' => record[:todo].size
}
}
return h
end
|
#end_test(test) ⇒ Object
170
171
172
173
|
# File 'lib/rubytest/format/abstract_hash.rb', line 170
def end_test(test)
super(test)
$stdout, $stderr = @stdout, @stderr
end
|
#error(test, exception) ⇒ Hash
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
# File 'lib/rubytest/format/abstract_hash.rb', line 128
def error(test, exception)
h = {}
h['type' ] = 'test'
h['status'] = 'error'
merge_subtype h, test
merge_priority h, test, exception
merge_setup h, test
merge_label h, test
merge_source h, test
merge_exception h, test, exception, true
merge_output h
merge_time h
return h
end
|
#fail(test, exception) ⇒ Hash
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/rubytest/format/abstract_hash.rb', line 106
def fail(test, exception)
h = {}
h['type' ] = 'test'
h['status'] = 'fail'
merge_subtype h, test
merge_priority h, test, exception
merge_setup h, test
merge_label h, test
merge_source h, test
merge_exception h, test, exception
merge_output h
merge_time h
return h
end
|
#pass(test) ⇒ Hash
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/rubytest/format/abstract_hash.rb', line 86
def pass(test) h = {}
h['type' ] = 'test'
h['status'] = 'pass'
merge_subtype h, test
merge_setup h, test
merge_label h, test
merge_source h, test
merge_output h
merge_time h
return h
end
|
#skip_test(test) ⇒ Hash
TODO:
Maybe the terms can ultimately be reconciled.
Ruby Test use the term “skip”, where as TAP-Y/J uses “omit”.
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/rubytest/format/abstract_hash.rb', line 65
def skip_test(test)
h = {}
h['type' ] = 'test'
h['status'] = 'omit'
merge_subtype h, test
merge_setup h, test
merge_label h, test
merge_source h, test
merge_output h
merge_time h
return h
end
|
#todo(test, exception) ⇒ Hash
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# File 'lib/rubytest/format/abstract_hash.rb', line 150
def todo(test, exception)
h = {}
h['type' ] = 'test'
h['status'] = 'todo'
merge_subtype h, test
merge_priority h, test, exception
merge_setup h, test
merge_label h, test
merge_source h, test
merge_exception h, test, exception
merge_output h
merge_time h
return h
end
|