126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
# File 'lib/tdriver/report/report_test_unit.rb', line 126
def create_test_unit_formatter()
$stderr.puts "Warning: TDriverReport#create_test_unit_formatter() is deprecated please use only \"include TDriverReportTestUnit\" instead of
begin
include TDriverReport
create_test_unit_formatter()
end
module Test #:nodoc:all
module Unit
module UI
module Console
class TestRunner
def create_mediator(suite)
# swap in TDriver custom mediator
return TDriverReport::TestUnit.new(suite)
end
end
end
end
end
end
"
eval "
require 'test/unit'
require 'test/unit/ui/console/testrunner'
#class for listening test unit execution process
class TestUnit < Test::Unit::UI::TestRunnerMediator
include TDriverReportCreator
def initialize(suite, report_mgr = nil)
super(suite)
@tc_result=nil
@current_suite_name=suite.name
@current_test_name=nil
add_listener(Test::Unit::UI::TestRunnerMediator::STARTED, &method(:started))
add_listener(Test::Unit::TestCase::STARTED, &method(:test_started))
add_listener(Test::Unit::TestCase::FINISHED, &method(:test_finished))
add_listener(Test::Unit::TestResult::FAULT, &method(:fault))
end
def get_class_name(full_test_name) #:nodoc:
begin
name=full_test_name
name=name.gsub(/[)]/,'')
name_arr=name.split('(')
return [name_arr[1].gsub(/[:]/,'_'),name_arr[0].gsub(/[:]/,'_')]
rescue
return ['Ruby test',full_test_name]
end
end
#This method initializes new test run
#
# === params
# === returns
# === raises
def started(result)
start_run()
add_report_group(@current_suite_name+'|')
end
#This method starts a new test case
#
# === params
# === returns
# === raises
def test_started(name)
full_name=get_class_name(name)
@current_test_name=full_name[1]
add_report_group(@current_suite_name+':'+full_name[0]+'|')
start_test_case(@current_test_name)
add_test_case_group(full_name[0])
@tc_result='passed'
end
#This method records the test case result
#
# === params
# === returns
# === raises
def test_finished(name)
if @tc_result=='passed'
update_test_case('-')
end
end_test_case(@current_test_name,@tc_result)
end
#This method records the test case fault result
#
# === params
# === returns
# === raises
def fault(fault)
capture_screen_test_case()
update_test_case(fault)
@tc_result='failed'
end
end
"
end
|