14728
|
1 |
"
|
|
2 |
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague
|
|
3 |
Copyright (c) 2009-2010 eXept Software AG
|
|
4 |
|
|
5 |
Permission is hereby granted, free of charge, to any person
|
|
6 |
obtaining a copy of this software and associated documentation
|
|
7 |
files (the 'Software'), to deal in the Software without
|
|
8 |
restriction, including without limitation the rights to use,
|
|
9 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10 |
copies of the Software, and to permit persons to whom the
|
|
11 |
Software is furnished to do so, subject to the following
|
|
12 |
conditions:
|
|
13 |
|
|
14 |
The above copyright notice and this permission notice shall be
|
|
15 |
included in all copies or substantial portions of the Software.
|
|
16 |
|
|
17 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
18 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
19 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
21 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
22 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
23 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
24 |
OTHER DEALINGS IN THE SOFTWARE.
|
|
25 |
"
|
|
26 |
"{ Package: 'stx:libtool' }"
|
|
27 |
|
|
28 |
"{ NameSpace: Tools }"
|
|
29 |
|
|
30 |
AbstractTestRunner subclass:#TestRunnerMini
|
|
31 |
instanceVariableNames:'runnerPanel selectedClassesHolder selectedProtocolsHolder
|
|
32 |
selectedMethodsHolder methodGeneratorHolder resultHolder
|
|
33 |
resultInfoHolder resultBackgroundColorHolder runningHolder
|
|
34 |
progressHolder progressIndicatorShownHolder infoHolder
|
|
35 |
testProcess allTestCases progressIndicator'
|
|
36 |
classVariableNames:''
|
|
37 |
poolDictionaries:''
|
|
38 |
category:'SUnit-UI'
|
|
39 |
!
|
|
40 |
|
|
41 |
Object subclass:#SuiteAndResult
|
|
42 |
instanceVariableNames:'suite result'
|
|
43 |
classVariableNames:''
|
|
44 |
poolDictionaries:''
|
|
45 |
privateIn:TestRunnerMini
|
|
46 |
!
|
|
47 |
|
|
48 |
!TestRunnerMini class methodsFor:'documentation'!
|
|
49 |
|
|
50 |
copyright
|
|
51 |
"
|
|
52 |
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague
|
|
53 |
Copyright (c) 2009-2010 eXept Software AG
|
|
54 |
|
|
55 |
Permission is hereby granted, free of charge, to any person
|
|
56 |
obtaining a copy of this software and associated documentation
|
|
57 |
files (the 'Software'), to deal in the Software without
|
|
58 |
restriction, including without limitation the rights to use,
|
|
59 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
60 |
copies of the Software, and to permit persons to whom the
|
|
61 |
Software is furnished to do so, subject to the following
|
|
62 |
conditions:
|
|
63 |
|
|
64 |
The above copyright notice and this permission notice shall be
|
|
65 |
included in all copies or substantial portions of the Software.
|
|
66 |
|
|
67 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
68 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
69 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
70 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
71 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
72 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
73 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
74 |
OTHER DEALINGS IN THE SOFTWARE.
|
|
75 |
"
|
|
76 |
!
|
|
77 |
|
|
78 |
documentation
|
|
79 |
"
|
|
80 |
a tiny runner to be embedded in a system browser
|
|
81 |
"
|
|
82 |
! !
|
|
83 |
|
|
84 |
!TestRunnerMini class methodsFor:'help specs'!
|
|
85 |
|
|
86 |
flyByHelpSpec
|
|
87 |
"This resource specification was automatically generated
|
|
88 |
by the UIHelpTool of ST/X."
|
|
89 |
|
|
90 |
"Do not manually edit this!! If it is corrupted,
|
|
91 |
the UIHelpTool may not be able to read the specification."
|
|
92 |
|
|
93 |
"
|
|
94 |
UIHelpTool openOnClass:Tools::TestRunnerEmbedded
|
|
95 |
"
|
|
96 |
|
|
97 |
<resource: #help>
|
|
98 |
|
|
99 |
^ super flyByHelpSpec addPairsFrom:#(
|
|
100 |
|
|
101 |
#debugSelected
|
|
102 |
'Run the selected test(s) with debugging enabled'
|
|
103 |
|
|
104 |
#runAll
|
|
105 |
'Run all tests'
|
|
106 |
|
|
107 |
#runFailed
|
|
108 |
'Only rerun failed tests'
|
|
109 |
|
|
110 |
#runSelected
|
|
111 |
'Run the selected test(s)'
|
|
112 |
|
|
113 |
#stopRun
|
|
114 |
'Stop the test-run'
|
|
115 |
|
|
116 |
)
|
|
117 |
|
|
118 |
"Created: / 04-06-2012 / 19:27:47 / cg"
|
|
119 |
! !
|
|
120 |
|
|
121 |
!TestRunnerMini class methodsFor:'image specs'!
|
|
122 |
|
|
123 |
pinIcon
|
|
124 |
"This resource specification was automatically generated
|
|
125 |
by the ImageEditor of ST/X."
|
|
126 |
|
|
127 |
"Do not manually edit this!! If it is corrupted,
|
|
128 |
the ImageEditor may not be able to read the specification."
|
|
129 |
|
|
130 |
"
|
|
131 |
self pinIcon inspect
|
|
132 |
ImageEditor openOnClass:self andSelector:#pinIcon
|
|
133 |
Icon flushCachedIcons
|
|
134 |
"
|
|
135 |
|
|
136 |
<resource: #image>
|
|
137 |
|
|
138 |
^Icon
|
|
139 |
constantNamed:'Tools::TestRunnerEmbedded pinIcon'
|
|
140 |
ifAbsentPut:[(Depth8Image new) width:14; height:13; bits:(ByteArray fromPackedString:'
|
|
141 |
NC 8NC 8NC 8NB8/L# 8NC 8NC 8NC 8J3@1L# 8NC 8NC 8NB80J3@/APXDB@8OB3L+L3L0KB8RD1TVE1$ZJ2<0L2,8N@TGA@$JD@00KR<-M3 8M04MCP4M
|
|
142 |
CPD0KSL7NC 7CRD\HRDAHRD!!HS\8NCXMH!!4"H!!4TGQ4#M# 8M@4[IRP^IQ8XIRT5NC *CRX_I!!<_I!!<QG2$8N@LMI2 ''HB\ HB\ @# 8@@@@@@@@@@@@@@@@
|
|
143 |
NC b') ; colorMapFromArray:#[136 149 174 23 50 93 145 154 169 144 154 168 48 116 186 68 118 170 70 119 171 70 120 171 62 133 196 62 132 195 93 155 206 170 202 228 171 202 228 197 223 244 93 156 206 132 180 218 132 181 218 205 228 246 90 156 204 111 182 226 179 216 240 88 182 232 115 196 236 153 212 241 186 225 246 189 226 245 217 238 249 242 251 255 235 249 255 238 250 255 241 251 255 245 252 255 248 253 255 235 250 255 238 251 255 239 251 255 241 252 255 242 252 255 245 253 255 248 254 255 247 254 255 157 161 160 157 162 160 0 114 54 0 97 46 0 82 39 0 149 62 53 155 88 114 182 73 125 181 81 163 202 129 159 167 110 170 170 151 171 169 151 183 177 142 191 182 136 255 255 255]; mask:((Depth1Image new) width:14; height:13; bits:(ByteArray fromPackedString:'@C @O@A<??3?<O?0??C?<O?0??C?<O?0??@b') ; yourself); yourself]
|
|
144 |
! !
|
|
145 |
|
|
146 |
!TestRunnerMini class methodsFor:'interface specs'!
|
|
147 |
|
|
148 |
windowSpec
|
|
149 |
"This resource specification was automatically generated
|
|
150 |
by the UIPainter of ST/X."
|
|
151 |
|
|
152 |
"Do not manually edit this!! If it is corrupted,
|
|
153 |
the UIPainter may not be able to read the specification."
|
|
154 |
|
|
155 |
"
|
|
156 |
UIPainter new openOnClass:Tools::TestRunnerMini andSelector:#windowSpec
|
|
157 |
Tools::TestRunnerMini new openInterface:#windowSpec
|
|
158 |
Tools::TestRunnerMini open
|
|
159 |
"
|
|
160 |
|
|
161 |
<resource: #canvas>
|
|
162 |
|
|
163 |
^
|
|
164 |
#(FullSpec
|
|
165 |
name: windowSpec
|
|
166 |
window:
|
|
167 |
(WindowSpec
|
|
168 |
label: 'Test Runner Embedded'
|
|
169 |
name: 'Test Runner Embedded'
|
|
170 |
min: (Point 10 10)
|
|
171 |
bounds: (Rectangle 0 0 600 50)
|
|
172 |
)
|
|
173 |
component:
|
|
174 |
(SpecCollection
|
|
175 |
collection: (
|
|
176 |
(HorizontalPanelViewSpec
|
|
177 |
name: 'RunnerInnerBox'
|
|
178 |
layout: (LayoutFrame 0 0 0 0 0 1 0 1)
|
|
179 |
backgroundChannel: resultBackgroundColorAspect
|
|
180 |
horizontalLayout: rightSpaceFit
|
|
181 |
verticalLayout: center
|
|
182 |
horizontalSpace: 0
|
|
183 |
elementsChangeSize: true
|
|
184 |
component:
|
|
185 |
(SpecCollection
|
|
186 |
collection: (
|
|
187 |
(ViewSpec
|
|
188 |
name: 'RunnerInfoBox'
|
|
189 |
backgroundChannel: resultBackgroundColorAspect
|
|
190 |
component:
|
|
191 |
(SpecCollection
|
|
192 |
collection: (
|
|
193 |
(ViewSpec
|
|
194 |
name: 'ProgressPanel'
|
|
195 |
layout: (LayoutFrame 0 0 0 0 0 1 0 1)
|
|
196 |
initiallyInvisible: true
|
|
197 |
visibilityChannel: progressIndicatorShownHolder
|
|
198 |
backgroundChannel: resultBackgroundColorAspect
|
|
199 |
component:
|
|
200 |
(SpecCollection
|
|
201 |
collection: (
|
|
202 |
(ProgressIndicatorSpec
|
|
203 |
name: 'RunningProgress'
|
|
204 |
layout: (LayoutFrame 5 0 -10 0.5 -5 1 10 0.5)
|
|
205 |
model: progressHolder
|
|
206 |
postBuildCallback: postBuildProgressIndicator:
|
|
207 |
)
|
|
208 |
)
|
|
209 |
|
|
210 |
)
|
|
211 |
)
|
|
212 |
(LabelSpec
|
|
213 |
label: 'Run tests first!!'
|
|
214 |
name: 'ResultName'
|
|
215 |
layout: (LayoutFrame 22 0 0 0 0 1 -10 1)
|
|
216 |
backgroundChannel: resultBackgroundColorAspect
|
|
217 |
foregroundColor: (Color 100.0 100.0 100.0)
|
|
218 |
translateLabel: true
|
|
219 |
labelChannel: resultNameAspect
|
|
220 |
adjust: left
|
|
221 |
)
|
|
222 |
(ActionButtonSpec
|
|
223 |
name: 'Button3'
|
|
224 |
layout: (LayoutFrame 5 0 3 0 21 0 17 0)
|
|
225 |
level: 0
|
|
226 |
visibilityChannel: pinButtonVisibleHolder
|
|
227 |
backgroundChannel: resultBackgroundColorAspect
|
|
228 |
hasCharacterOrientedLabel: false
|
|
229 |
translateLabel: true
|
|
230 |
foregroundChannel: resultBackgroundColorAspect
|
|
231 |
labelChannel: pinIcon
|
|
232 |
model: pin
|
|
233 |
)
|
|
234 |
(LabelSpec
|
|
235 |
name: 'ResultInfo'
|
|
236 |
layout: (LayoutFrame 22 0 -10 1 0 1 0 1)
|
|
237 |
style: (FontDescription helvetica medium roman 8 #'iso10646-1')
|
|
238 |
backgroundChannel: resultBackgroundColorAspect
|
|
239 |
foregroundColor: (Color 100.0 100.0 100.0)
|
|
240 |
translateLabel: true
|
|
241 |
labelChannel: resultInfoAspect
|
|
242 |
adjust: left
|
|
243 |
)
|
|
244 |
)
|
|
245 |
|
|
246 |
)
|
|
247 |
extent: (Point 296 30)
|
|
248 |
)
|
|
249 |
(ActionButtonSpec
|
|
250 |
label: 'Debug'
|
|
251 |
name: 'DebugButton'
|
|
252 |
activeHelpKey: debugSelected
|
|
253 |
translateLabel: true
|
|
254 |
model: debug
|
|
255 |
enableChannel: runEnabledHolder
|
|
256 |
extent: (Point 60 25)
|
|
257 |
)
|
|
258 |
(ActionButtonSpec
|
|
259 |
label: 'Stop'
|
|
260 |
name: 'Button2'
|
|
261 |
activeHelpKey: stopRun
|
|
262 |
visibilityChannel: runningHolder
|
|
263 |
translateLabel: true
|
|
264 |
model: stop
|
|
265 |
extent: (Point 60 25)
|
|
266 |
)
|
|
267 |
(ActionButtonSpec
|
|
268 |
label: 'Run'
|
|
269 |
name: 'Run'
|
|
270 |
activeHelpKey: runSelected
|
|
271 |
visibilityChannel: notRunningHolder
|
|
272 |
translateLabel: true
|
|
273 |
model: run
|
|
274 |
enableChannel: runEnabledHolder
|
|
275 |
extent: (Point 60 25)
|
|
276 |
)
|
|
277 |
(ActionButtonSpec
|
|
278 |
label: ' Failed'
|
|
279 |
name: 'Button1'
|
|
280 |
activeHelpKey: runFailed
|
|
281 |
visibilityChannel: runFailedButtonVisibleHolder
|
|
282 |
translateLabel: true
|
|
283 |
model: runFailed
|
|
284 |
enableChannel: runFailedEnabledHolder
|
|
285 |
extent: (Point 60 25)
|
|
286 |
)
|
|
287 |
(ActionButtonSpec
|
|
288 |
label: 'Run all'
|
|
289 |
name: 'RunAll'
|
|
290 |
activeHelpKey: runAll
|
|
291 |
visibilityChannel: runAllButtonVisibleHolder
|
|
292 |
translateLabel: true
|
|
293 |
model: runAll
|
|
294 |
enableChannel: runAllEnabledHolder
|
|
295 |
extent: (Point 60 25)
|
|
296 |
)
|
|
297 |
(ViewSpec
|
|
298 |
name: 'Spacer'
|
|
299 |
backgroundChannel: resultBackgroundColorAspect
|
|
300 |
extent: (Point 5 50)
|
|
301 |
)
|
|
302 |
)
|
|
303 |
|
|
304 |
)
|
|
305 |
postBuildCallback: postBuildRunnerPanel:
|
|
306 |
)
|
|
307 |
)
|
|
308 |
|
|
309 |
)
|
|
310 |
)
|
|
311 |
|
|
312 |
! !
|
|
313 |
|
|
314 |
!TestRunnerMini class methodsFor:'queries'!
|
|
315 |
|
|
316 |
shouldRememberLastExtent
|
|
317 |
"to be redefined by concrete applications:
|
|
318 |
if true is answered, the application's extent is remembered on close
|
|
319 |
and used as a default when opened the next time"
|
|
320 |
|
|
321 |
^ false
|
|
322 |
|
|
323 |
"Created: / 22-09-2014 / 14:02:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
324 |
! !
|
|
325 |
|
|
326 |
!TestRunnerMini methodsFor:'accessing'!
|
|
327 |
|
|
328 |
allTestCases
|
|
329 |
allTestCases isNil ifTrue:[
|
|
330 |
self updateTestCases
|
|
331 |
].
|
|
332 |
^ allTestCases
|
|
333 |
!
|
|
334 |
|
|
335 |
infoHolder:something
|
|
336 |
"to show something in the browsers info area (near the bottom"
|
|
337 |
|
|
338 |
infoHolder := something.
|
|
339 |
|
|
340 |
"Created: / 05-07-2011 / 16:22:24 / cg"
|
|
341 |
!
|
|
342 |
|
|
343 |
invalidateAllTestCases
|
|
344 |
allTestCases := nil
|
|
345 |
!
|
|
346 |
|
|
347 |
selectedTestMethods
|
|
348 |
|
|
349 |
| selectedClass |
|
|
350 |
selectedClass := self theSingleTestCase.
|
|
351 |
|
|
352 |
^ (self selectedMethodsHolder value ? #()) select:
|
|
353 |
[:mthd | | cls |
|
|
354 |
(cls := selectedClass) isNil ifTrue:[cls := mthd mclass].
|
|
355 |
(self isTestCaseLike:selectedClass)
|
|
356 |
and:[ selectedClass isTestSelector:mthd selector ] ]
|
|
357 |
|
|
358 |
"Created: / 15-03-2010 / 13:21:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
359 |
"Modified: / 22-07-2011 / 15:46:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
360 |
"Modified: / 02-08-2011 / 17:46:38 / cg"
|
|
361 |
!
|
|
362 |
|
|
363 |
selectedTestMethodsFromProtocols:protocols
|
|
364 |
|
|
365 |
|methods generator selectedClass|
|
|
366 |
|
|
367 |
methods := Set new.
|
|
368 |
generator := self methodGeneratorHolder value.
|
|
369 |
selectedClass := self theSingleTestCase.
|
|
370 |
|
|
371 |
generator notNil ifTrue:[
|
|
372 |
generator do: [:cls :cat :sel :mthd |
|
|
373 |
(mthd notNil
|
|
374 |
and:[ (self isTestCaseLike:(selectedClass ? cls))
|
|
375 |
and:[ (selectedClass ? cls) isTestSelector:sel ] ])
|
|
376 |
ifTrue:[ methods add:mthd ]
|
|
377 |
]
|
|
378 |
] ifFalse:[
|
|
379 |
allTestCases do: [:cls |
|
|
380 |
cls methodsDo: [:mthd |
|
|
381 |
((protocols includes:mthd category) and:[ cls isTestSelector:mthd selector ])
|
|
382 |
ifTrue:[
|
|
383 |
methods add:mthd
|
|
384 |
]
|
|
385 |
]
|
|
386 |
]
|
|
387 |
].
|
|
388 |
^ methods
|
|
389 |
|
|
390 |
"Created: / 15-03-2010 / 19:50:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
391 |
"Modified: / 22-07-2011 / 15:53:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
392 |
"Modified (format): / 04-06-2012 / 19:05:32 / cg"
|
|
393 |
!
|
|
394 |
|
|
395 |
selectedTestMethodsFromProtocols:protocols inClass:aTestClass
|
|
396 |
|
|
397 |
|methods generator|
|
|
398 |
|
|
399 |
methods := Set new.
|
|
400 |
generator := self methodGeneratorHolder value.
|
|
401 |
|
|
402 |
generator notNil ifTrue:[
|
|
403 |
generator do: [:cls :cat :sel :mthd |
|
|
404 |
(mthd notNil
|
|
405 |
and:[ (self isTestCaseLike:(aTestClass ? cls))
|
|
406 |
and:[ (aTestClass ? cls) isTestSelector:sel ] ])
|
|
407 |
ifTrue:[ methods add:mthd ]
|
|
408 |
]
|
|
409 |
] ifFalse:[
|
|
410 |
self allTestCases do: [:cls |
|
|
411 |
cls methodsDo: [:mthd |
|
|
412 |
((protocols includes:mthd category) and:[ cls isTestSelector:mthd selector ])
|
|
413 |
ifTrue:[
|
|
414 |
methods add:mthd
|
|
415 |
]
|
|
416 |
]
|
|
417 |
]
|
|
418 |
].
|
|
419 |
^ methods
|
|
420 |
|
|
421 |
"Created: / 15-03-2010 / 19:50:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
422 |
"Modified: / 22-07-2011 / 15:53:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
423 |
"Modified (format): / 04-06-2012 / 19:05:32 / cg"
|
|
424 |
!
|
|
425 |
|
|
426 |
selectedTestMethodsInClass:testClass
|
|
427 |
^ (self selectedMethodsHolder value ? #()) select:
|
|
428 |
[:mthd | | cls |
|
|
429 |
(cls := testClass) isNil ifTrue:[cls := mthd mclass].
|
|
430 |
(self isTestCaseLike:testClass)
|
|
431 |
and:[ testClass isTestSelector:mthd selector ] ]
|
|
432 |
|
|
433 |
"Created: / 15-03-2010 / 13:21:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
434 |
"Modified: / 22-07-2011 / 15:46:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
435 |
"Modified: / 02-08-2011 / 17:46:38 / cg"
|
|
436 |
!
|
|
437 |
|
|
438 |
theSingleTestCase
|
|
439 |
|
|
440 |
self allTestCases isEmptyOrNil ifTrue:[^nil].
|
|
441 |
allTestCases size > 1 ifTrue:[^nil].
|
|
442 |
|
|
443 |
^allTestCases anyOne.
|
|
444 |
|
|
445 |
"Created: / 22-07-2011 / 15:44:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
446 |
! !
|
|
447 |
|
|
448 |
!TestRunnerMini methodsFor:'actions'!
|
|
449 |
|
|
450 |
debug
|
|
451 |
| suiteAndResult suite result |
|
|
452 |
|
|
453 |
suiteAndResult := self resultHolder value.
|
|
454 |
suite := suiteAndResult suiteForRun.
|
|
455 |
"/ suite tests size ~= 1 ifTrue:[^self breakPoint: #jv].
|
|
456 |
"/ test := suiteAndResult suite tests anyOne.
|
|
457 |
result := TestResult defaultResultClass new.
|
|
458 |
suiteAndResult := SuiteAndResult suite: suite result: result.
|
|
459 |
|
|
460 |
self stop.
|
|
461 |
|
|
462 |
"/ debug run is synchronous
|
|
463 |
[
|
|
464 |
self runningHolder value:true.
|
|
465 |
|
|
466 |
suite tests do:[:test |
|
|
467 |
[
|
|
468 |
test debug.
|
|
469 |
] ifCurtailed:[
|
|
470 |
result failureOutcomes add: test.
|
|
471 |
self resultHolder value:suiteAndResult; changed.
|
|
472 |
].
|
|
473 |
|
|
474 |
(test class testSelectorPassed:test selector) ifTrue:[
|
|
475 |
"/ result := TestResult defaultResultClass new.
|
|
476 |
"/ result passed add: test.
|
|
477 |
"/ suiteAndResult := SuiteAndResult suite: suite result: result.
|
|
478 |
result passedOutcomes add: test.
|
|
479 |
self resultHolder value:suiteAndResult; changed.
|
|
480 |
] ifFalse:[
|
|
481 |
(test class testSelectorFailed:test selector) ifTrue:[
|
|
482 |
"/ result := TestResult defaultResultClass new.
|
|
483 |
"/ result failures add: test.
|
|
484 |
"/ suiteAndResult := SuiteAndResult suite: suite result: result.
|
|
485 |
result failureOutcomes add: test.
|
|
486 |
self resultHolder value:suiteAndResult; changed.
|
|
487 |
]
|
|
488 |
]
|
|
489 |
].
|
|
490 |
] ensure:[
|
|
491 |
self runningHolder value:false.
|
|
492 |
].
|
|
493 |
|
|
494 |
"Created: / 15-03-2010 / 15:43:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
495 |
"Modified: / 07-07-2011 / 11:33:48 / Jan Vrany <jan.vrant@fit.cvut,cz>"
|
|
496 |
"Modified: / 04-06-2012 / 19:46:38 / cg"
|
|
497 |
"Modified: / 03-12-2012 / 14:02:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
498 |
!
|
|
499 |
|
|
500 |
pin
|
|
501 |
| runner screen |
|
|
502 |
|
|
503 |
runner := TestRunnerMini new.
|
|
504 |
runner selectedMethodsHolder: self selectedMethodsHolder copy asValue.
|
|
505 |
runner selectedProtocolsHolder: self selectedProtocolsHolder copy asValue.
|
|
506 |
runner selectedClassesHolder: self selectedClassesHolder copy asValue.
|
|
507 |
|
|
508 |
runner allButOpen.
|
|
509 |
|
|
510 |
screen := Screen current.
|
|
511 |
(screen notNil and:[ screen platformName == #X11 ]) ifTrue:[
|
|
512 |
"/ Use EWMH hint to tell the WM that the window is
|
|
513 |
"/ a sort of floating tool so WM can decorate it according to
|
|
514 |
"/ DE standards.
|
|
515 |
runner window id isNil ifTrue:[
|
|
516 |
runner window create.
|
|
517 |
].
|
|
518 |
screen setWindowType:#'_NET_WM_WINDOW_TYPE_UTILITY' in:runner window id.
|
|
519 |
].
|
|
520 |
runner open.
|
|
521 |
|
|
522 |
"Modified: / 23-09-2014 / 10:13:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
523 |
!
|
|
524 |
|
|
525 |
run
|
|
526 |
|suite|
|
|
527 |
|
|
528 |
resultHolder value isNil ifTrue:[
|
|
529 |
suite := self suiteForRun
|
|
530 |
] ifFalse:[
|
|
531 |
suite := resultHolder value suiteForRun
|
|
532 |
].
|
|
533 |
self run:suite
|
|
534 |
|
|
535 |
"Created: / 10-03-2010 / 19:42:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
536 |
"Modified: / 22-08-2011 / 09:58:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
537 |
"Modified: / 09-10-2011 / 10:56:39 / cg"
|
|
538 |
!
|
|
539 |
|
|
540 |
run:suite
|
|
541 |
^self run: suite debug: false
|
|
542 |
|
|
543 |
"Created: / 11-03-2010 / 10:22:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
544 |
"Modified: / 09-06-2012 / 20:23:58 / cg"
|
|
545 |
"Modified: / 03-12-2012 / 13:59:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
546 |
!
|
|
547 |
|
|
548 |
run:suite debug: debug
|
|
549 |
|suiteAndResult numTests|
|
|
550 |
|
|
551 |
numTests := suite tests size.
|
|
552 |
numTests == 0 ifTrue:[
|
|
553 |
^ self
|
|
554 |
].
|
|
555 |
|
|
556 |
self stop.
|
|
557 |
|
|
558 |
testProcess := [
|
|
559 |
|result incr run|
|
|
560 |
|
|
561 |
result := debug ifFalse:[TestResult new] ifTrue:[TestResultForRunWithDebug].
|
|
562 |
[
|
|
563 |
self runningHolder value:true.
|
|
564 |
self progressIndicatorShownHolder value:(numTests > 1).
|
|
565 |
self progressHolder value:0.
|
|
566 |
incr := 100 / numTests.
|
|
567 |
run := 0.
|
|
568 |
result := suite
|
|
569 |
run: result
|
|
570 |
beforeEachDo:[:test :result |
|
|
571 |
infoHolder notNil ifTrue:[
|
|
572 |
infoHolder value:('Running "%1-%2"...'
|
|
573 |
bindWith:test name
|
|
574 |
with:test getTestName allBold)
|
|
575 |
]
|
|
576 |
]
|
|
577 |
afterEachDo:[:test :result |
|
|
578 |
run := run + 1.
|
|
579 |
self progressHolder value:(incr * run) truncated "rounded".
|
|
580 |
infoHolder notNil ifTrue:[
|
|
581 |
infoHolder value:('Done.')
|
|
582 |
]
|
|
583 |
]
|
|
584 |
debug: debug.
|
|
585 |
suiteAndResult := SuiteAndResult suite:suite result:result.
|
|
586 |
] ensure:[
|
|
587 |
self progressIndicatorShownHolder value:false.
|
|
588 |
self resultHolder setValue:nil; value:suiteAndResult; changed.
|
|
589 |
self runningHolder value:false.
|
|
590 |
]
|
|
591 |
] newProcess.
|
|
592 |
|
|
593 |
testProcess priority:(Processor userBackgroundPriority).
|
|
594 |
testProcess resume.
|
|
595 |
|
|
596 |
"Created: / 03-12-2012 / 13:59:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
597 |
!
|
|
598 |
|
|
599 |
runAll
|
|
600 |
|
|
601 |
self run: (self suiteForRunAll).
|
|
602 |
|
|
603 |
"Created: / 10-03-2010 / 19:42:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
604 |
"Modified: / 15-03-2010 / 13:12:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
605 |
"Modified: / 04-06-2012 / 19:00:14 / cg"
|
|
606 |
!
|
|
607 |
|
|
608 |
runFailed
|
|
609 |
self run: self suiteForRunFailed.
|
|
610 |
|
|
611 |
"Created: / 04-06-2012 / 18:32:19 / cg"
|
|
612 |
!
|
|
613 |
|
|
614 |
runWithDebug
|
|
615 |
"/ cg: I really do not want to run them twice to get a debugger
|
|
616 |
"/ - I want to run them either with a debugger coming right away, or not.
|
|
617 |
|
|
618 |
| suiteAndResult suite|
|
|
619 |
|
|
620 |
suiteAndResult := self resultHolder value.
|
|
621 |
suiteAndResult isNil ifTrue:[
|
|
622 |
suite := self suiteForRun.
|
|
623 |
] ifFalse:[
|
|
624 |
suite := suiteAndResult suiteForRun.
|
|
625 |
].
|
|
626 |
|
|
627 |
self run: suite debug: true
|
|
628 |
|
|
629 |
|
|
630 |
|
|
631 |
"/ suiteAndResult suite tests size ~= 1 ifTrue:[^self breakPoint: #jv].
|
|
632 |
"/ [suiteAndResult suite tests anyOne debug] fork
|
|
633 |
|
|
634 |
"Created: / 05-07-2011 / 18:45:43 / cg"
|
|
635 |
"Modified: / 09-10-2011 / 10:55:46 / cg"
|
|
636 |
"Modified: / 03-12-2012 / 13:59:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
637 |
!
|
|
638 |
|
|
639 |
stop
|
|
640 |
|p|
|
|
641 |
|
|
642 |
(p := testProcess) notNil ifTrue:[
|
|
643 |
testProcess := nil.
|
|
644 |
p terminate
|
|
645 |
].
|
|
646 |
|
|
647 |
"Created: / 04-06-2012 / 18:34:07 / cg"
|
|
648 |
! !
|
|
649 |
|
|
650 |
!TestRunnerMini methodsFor:'aspects'!
|
|
651 |
|
|
652 |
debugVisibleAspect
|
|
653 |
^ BlockValue
|
|
654 |
with:[:model |
|
|
655 |
model notNil
|
|
656 |
and:[ model testCount == 1
|
|
657 |
and:[ model hasFailuresOrErrors ]]
|
|
658 |
]
|
|
659 |
argument:self resultHolder
|
|
660 |
|
|
661 |
"Created: / 15-03-2010 / 15:40:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
662 |
"Modified: / 02-08-2011 / 18:19:14 / cg"
|
|
663 |
!
|
|
664 |
|
|
665 |
notRunningHolder
|
|
666 |
^ BlockValue forLogicalNot:(self runningHolder)
|
|
667 |
|
|
668 |
"Created: / 04-06-2012 / 18:38:48 / cg"
|
|
669 |
!
|
|
670 |
|
|
671 |
progressHolder
|
|
672 |
"return/create the 'progressHolder' value holder (automatically generated)"
|
|
673 |
|
|
674 |
progressHolder isNil ifTrue:[
|
|
675 |
progressHolder := ValueHolder new.
|
|
676 |
].
|
|
677 |
^ progressHolder
|
|
678 |
!
|
|
679 |
|
|
680 |
progressIndicatorShownHolder
|
|
681 |
progressIndicatorShownHolder isNil ifTrue:[
|
|
682 |
progressIndicatorShownHolder := ValueHolder with: false.
|
|
683 |
].
|
|
684 |
^ progressIndicatorShownHolder
|
|
685 |
|
|
686 |
"Modified: / 15-03-2010 / 20:29:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
687 |
"Modified (comment): / 04-06-2012 / 18:38:52 / cg"
|
|
688 |
"Created: / 04-06-2012 / 19:42:59 / cg"
|
|
689 |
!
|
|
690 |
|
|
691 |
resultBackgroundColorAspect
|
|
692 |
<resource: #uiAspect>
|
|
693 |
resultBackgroundColorHolder isNil ifTrue:[
|
|
694 |
resultBackgroundColorHolder := BlockValue
|
|
695 |
with:[:result :running |
|
|
696 |
running ifTrue:[
|
|
697 |
self class currentlyRunningColor
|
|
698 |
"/ View defaultBackgroundColor
|
|
699 |
] ifFalse:[
|
|
700 |
result isNil ifTrue:[
|
|
701 |
self class notRunColor
|
|
702 |
] ifFalse:[
|
|
703 |
result color
|
|
704 |
]
|
|
705 |
].
|
|
706 |
]
|
|
707 |
argument:self resultHolder
|
|
708 |
argument:self runningHolder.
|
|
709 |
resultBackgroundColorHolder
|
|
710 |
onChangeEvaluate:[
|
|
711 |
runnerPanel notNil ifTrue:[
|
|
712 |
runnerPanel backgroundColor:resultBackgroundColorHolder value
|
|
713 |
]
|
|
714 |
].
|
|
715 |
].
|
|
716 |
^ resultBackgroundColorHolder.
|
|
717 |
|
|
718 |
"Created: / 15-03-2010 / 15:22:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
719 |
"Modified: / 04-06-2012 / 19:40:11 / cg"
|
|
720 |
"Modified: / 23-09-2014 / 09:46:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
721 |
!
|
|
722 |
|
|
723 |
resultHolder
|
|
724 |
"return/create the 'resultHolder' value holder (automatically generated)"
|
|
725 |
|
|
726 |
resultHolder isNil ifTrue:[
|
|
727 |
resultHolder := ValueHolder new.
|
|
728 |
].
|
|
729 |
^ resultHolder
|
|
730 |
!
|
|
731 |
|
|
732 |
resultInfoAspect
|
|
733 |
^ BlockValue
|
|
734 |
with:[:model | model isNil ifTrue:[ '' ] ifFalse:[ model info ] ]
|
|
735 |
argument:self resultHolder
|
|
736 |
|
|
737 |
"Created: / 15-03-2010 / 20:22:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
738 |
"Modified: / 02-08-2011 / 18:20:26 / cg"
|
|
739 |
!
|
|
740 |
|
|
741 |
resultNameAspect
|
|
742 |
^ BlockValue
|
|
743 |
with:[:model | model isNil ifTrue:[ 'Run the tests!!' ] ifFalse:[ model name ] ]
|
|
744 |
argument:self resultHolder
|
|
745 |
|
|
746 |
"Created: / 15-03-2010 / 14:57:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
747 |
"Modified: / 15-03-2010 / 20:17:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
748 |
"Modified: / 02-08-2011 / 18:20:38 / cg"
|
|
749 |
!
|
|
750 |
|
|
751 |
runAllEnabledHolder
|
|
752 |
|
|
753 |
^ self notRunningHolder
|
|
754 |
|
|
755 |
"Created: / 07-09-2010 / 09:15:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
756 |
"Modified: / 04-06-2012 / 18:40:46 / cg"
|
|
757 |
!
|
|
758 |
|
|
759 |
runEnabledHolder
|
|
760 |
^BlockValue
|
|
761 |
with:
|
|
762 |
[:result :running |
|
|
763 |
|
|
764 |
running not
|
|
765 |
and:[ result notNil
|
|
766 |
and:[ result testCount > 0 ]]
|
|
767 |
]
|
|
768 |
argument: self resultHolder
|
|
769 |
argument: self runningHolder
|
|
770 |
|
|
771 |
"Created: / 07-09-2010 / 09:15:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
772 |
"Modified: / 04-06-2012 / 18:52:41 / cg"
|
|
773 |
!
|
|
774 |
|
|
775 |
runFailedEnabledHolder
|
|
776 |
^BlockValue
|
|
777 |
with:
|
|
778 |
[:running |
|
|
779 |
|
|
780 |
|result|
|
|
781 |
|
|
782 |
running not
|
|
783 |
and:[ TestResult notNil
|
|
784 |
and:[ TestResult isLoaded
|
|
785 |
and:[ result := self resultForSuite:self suiteForRunAll. result notNil
|
|
786 |
and:[ result hasFailuresOrErrors ]]]]
|
|
787 |
]
|
|
788 |
"/ argument: self resultHolder
|
|
789 |
argument: self runningHolder
|
|
790 |
|
|
791 |
"Created: / 07-09-2010 / 09:15:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
792 |
"Created: / 04-06-2012 / 18:28:12 / cg"
|
|
793 |
"Modified: / 18-07-2012 / 09:55:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
794 |
!
|
|
795 |
|
|
796 |
runningHolder
|
|
797 |
runningHolder isNil ifTrue:[
|
|
798 |
runningHolder := ValueHolder with: false.
|
|
799 |
].
|
|
800 |
^ runningHolder
|
|
801 |
|
|
802 |
"Modified: / 15-03-2010 / 20:29:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
803 |
"Modified (comment): / 04-06-2012 / 18:38:52 / cg"
|
|
804 |
!
|
|
805 |
|
|
806 |
stopEnabledHolder
|
|
807 |
^ self runningHolder
|
|
808 |
|
|
809 |
"Created: / 04-06-2012 / 18:29:01 / cg"
|
|
810 |
! !
|
|
811 |
|
|
812 |
!TestRunnerMini methodsFor:'aspects-visibility'!
|
|
813 |
|
|
814 |
pinButtonVisibleHolder
|
|
815 |
^ false
|
|
816 |
|
|
817 |
"Created: / 23-09-2014 / 10:11:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
818 |
!
|
|
819 |
|
|
820 |
runAllButtonVisibleHolder
|
|
821 |
^ false
|
|
822 |
|
|
823 |
"Created: / 23-09-2014 / 10:12:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
824 |
!
|
|
825 |
|
|
826 |
runFailedButtonVisibleHolder
|
|
827 |
^ false
|
|
828 |
|
|
829 |
"Created: / 23-09-2014 / 10:12:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
830 |
! !
|
|
831 |
|
|
832 |
!TestRunnerMini methodsFor:'change & update'!
|
|
833 |
|
|
834 |
invalidateSuiteAndResult
|
|
835 |
self resultHolder value:nil.
|
|
836 |
!
|
|
837 |
|
|
838 |
invalidateTestCases
|
|
839 |
allTestCases := nil.
|
|
840 |
!
|
|
841 |
|
|
842 |
update:aspect with:param from:sender
|
|
843 |
|
|
844 |
sender == Smalltalk ifTrue:[
|
|
845 |
aspect == #lastTestRunResult ifTrue:[
|
|
846 |
allTestCases notNil ifTrue:[
|
|
847 |
(allTestCases includesIdentical: param first) ifTrue:[
|
|
848 |
self invalidateSuiteAndResult. "/ updateTestSuiteAndResult.
|
|
849 |
self enqueueDelayedAction:[ self updateSuiteAndResult ].
|
|
850 |
^self
|
|
851 |
]
|
|
852 |
].
|
|
853 |
]
|
|
854 |
].
|
|
855 |
super update:aspect with:param from:sender
|
|
856 |
|
|
857 |
"Modified: / 23-09-2014 / 10:23:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
858 |
!
|
|
859 |
|
|
860 |
updateSuiteAndResult
|
|
861 |
| suite suiteAndResult |
|
|
862 |
|
|
863 |
self runningHolder value ifTrue:[^self].
|
|
864 |
self allTestCases isEmptyOrNil ifTrue:[^self].
|
|
865 |
|
|
866 |
suiteAndResult := SuiteAndResult
|
|
867 |
suite: (suite := self suiteForRun)
|
|
868 |
result: (self resultForSuite: suite).
|
|
869 |
self resultHolder value: suiteAndResult.
|
|
870 |
|
|
871 |
"Created: / 15-03-2010 / 19:41:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
872 |
"Modified: / 15-03-2010 / 20:55:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
873 |
"Modified: / 04-06-2012 / 19:03:15 / cg"
|
|
874 |
!
|
|
875 |
|
|
876 |
updateTestCases
|
|
877 |
allTestCases := ((self selectedClassesHolder value ? #())
|
|
878 |
select:[:cls | self isTestCaseLike:cls ]).
|
|
879 |
allTestCases := allTestCases asArray
|
|
880 |
|
|
881 |
"Created: / 11-03-2010 / 10:31:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
882 |
"Modified: / 24-01-2012 / 22:09:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
883 |
"Modified: / 04-06-2012 / 19:02:52 / cg"
|
|
884 |
!
|
|
885 |
|
|
886 |
updateTestSuiteAndResult
|
|
887 |
|
|
888 |
| suite suiteAndResult |
|
|
889 |
self runningHolder value ifTrue:[^self].
|
|
890 |
allTestCases isEmptyOrNil ifTrue:[^self].
|
|
891 |
suiteAndResult := SuiteAndResult
|
|
892 |
suite: (suite := self suiteForRun)
|
|
893 |
result: (self resultForSuite: suite).
|
|
894 |
self resultHolder value: suiteAndResult.
|
|
895 |
|
|
896 |
"Created: / 15-03-2010 / 19:41:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
897 |
"Modified: / 15-03-2010 / 20:55:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
898 |
"Modified: / 04-06-2012 / 19:03:15 / cg"
|
|
899 |
!
|
|
900 |
|
|
901 |
updateVisibility
|
|
902 |
|
|
903 |
self hasTestCaseSelected
|
|
904 |
ifTrue:[self show]
|
|
905 |
ifFalse:[self hide]
|
|
906 |
|
|
907 |
"Created: / 11-03-2010 / 09:02:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
908 |
! !
|
|
909 |
|
|
910 |
!TestRunnerMini methodsFor:'hooks'!
|
|
911 |
|
|
912 |
commonPostOpen
|
|
913 |
|
|
914 |
Smalltalk addDependent: self.
|
|
915 |
|
|
916 |
"Created: / 17-11-2011 / 20:59:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
917 |
!
|
|
918 |
|
|
919 |
postBuildRunnerPanel: aView
|
|
920 |
|
|
921 |
runnerPanel := aView.
|
|
922 |
runnerPanel backgroundColor: self resultBackgroundColorAspect value
|
|
923 |
|
|
924 |
"Created: / 15-03-2010 / 14:26:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
925 |
!
|
|
926 |
|
|
927 |
release
|
|
928 |
|
|
929 |
Smalltalk removeDependent: self.
|
|
930 |
|
|
931 |
"Created: / 23-09-2014 / 10:22:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
932 |
!
|
|
933 |
|
|
934 |
releaseAsSubCanvas
|
|
935 |
|
|
936 |
Smalltalk removeDependent: self.
|
|
937 |
|
|
938 |
"Created: / 17-11-2011 / 21:03:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
939 |
! !
|
|
940 |
|
|
941 |
!TestRunnerMini methodsFor:'private'!
|
|
942 |
|
|
943 |
isTestCaseLike:cls
|
|
944 |
|
|
945 |
^(super isTestCaseLike: cls) and:
|
|
946 |
[(cls askFor: #isAbstract) not]
|
|
947 |
|
|
948 |
"Modified: / 04-03-2011 / 06:54:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
949 |
!
|
|
950 |
|
|
951 |
postBuildProgressIndicator:aWidget
|
|
952 |
progressIndicator := aWidget
|
|
953 |
! !
|
|
954 |
|
|
955 |
!TestRunnerMini methodsFor:'queries'!
|
|
956 |
|
|
957 |
hasTestCaseSelected
|
|
958 |
|
|
959 |
^self allTestCases notEmptyOrNil
|
|
960 |
|
|
961 |
"Created: / 11-03-2010 / 09:06:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
962 |
"Modified: / 15-03-2010 / 20:54:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
963 |
"Modified: / 04-08-2011 / 20:42:10 / cg"
|
|
964 |
! !
|
|
965 |
|
|
966 |
!TestRunnerMini methodsFor:'utilities'!
|
|
967 |
|
|
968 |
resultForSuite:suite
|
|
969 |
|result|
|
|
970 |
|
|
971 |
result := TestResult defaultResultClass new.
|
|
972 |
suite tests do:[:test |
|
|
973 |
| sel cls |
|
|
974 |
|
|
975 |
sel := test selector.
|
|
976 |
cls := test class.
|
|
977 |
(cls testSelectorPassed:sel) ifTrue:[
|
|
978 |
result passedOutcomes add: (cls rememberedOutcomeFor: sel)
|
|
979 |
] ifFalse:[
|
|
980 |
(cls testSelectorError:sel) ifTrue:[
|
|
981 |
result errorOutcomes add:(cls rememberedOutcomeFor: sel)
|
|
982 |
] ifFalse:[
|
|
983 |
(cls testSelectorFailed:sel) ifTrue:[
|
|
984 |
result failureOutcomes add:(cls rememberedOutcomeFor: sel)
|
|
985 |
]
|
|
986 |
]
|
|
987 |
]
|
|
988 |
].
|
|
989 |
^ result
|
|
990 |
|
|
991 |
"Created: / 15-03-2010 / 19:46:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
992 |
"Modified: / 02-08-2011 / 18:20:00 / cg"
|
|
993 |
"Modified: / 20-08-2011 / 14:30:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
994 |
!
|
|
995 |
|
|
996 |
suiteForRun
|
|
997 |
"if methods are selected, a suite for those methods is built and returned.
|
|
998 |
If protocoly are selected, a suite for all methods in those protocols
|
|
999 |
is built and returned.
|
|
1000 |
Otherwise, a suite for all methods in the class is built and returned"
|
|
1001 |
|
|
1002 |
| testMethods protocols suite selectedClass |
|
|
1003 |
|
|
1004 |
selectedClass := self theSingleTestCase.
|
|
1005 |
selectedMethodsHolder value notEmptyOrNil ifTrue:[
|
|
1006 |
testMethods := self selectedTestMethods.
|
|
1007 |
suite := TestSuite named:(self suiteNameFromMethods:testMethods).
|
|
1008 |
testMethods do:[:mthd |
|
|
1009 |
| class selector |
|
|
1010 |
|
|
1011 |
class := selectedClass isNil ifTrue:[mthd mclass] ifFalse:[ selectedClass ].
|
|
1012 |
suite addTest:(class asTestCase selector:mthd selector)
|
|
1013 |
].
|
|
1014 |
^ suite
|
|
1015 |
].
|
|
1016 |
(protocols := selectedProtocolsHolder value) notEmptyOrNil ifTrue:[
|
|
1017 |
suite := TestSuite named:(self suiteNameFromProtocols:protocols).
|
|
1018 |
(self selectedTestMethodsFromProtocols:protocols inClass:selectedClass) do:[:mthd |
|
|
1019 |
| class selector |
|
|
1020 |
|
|
1021 |
class := selectedClass isNil ifTrue:[mthd mclass] ifFalse:[ selectedClass ].
|
|
1022 |
suite addTest:(class asTestCase selector:mthd selector)
|
|
1023 |
].
|
|
1024 |
^ suite
|
|
1025 |
].
|
|
1026 |
^ self suiteForRunAll
|
|
1027 |
|
|
1028 |
"Created: / 15-03-2010 / 13:13:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
1029 |
"Modified: / 04-08-2011 / 19:06:42 / cg"
|
|
1030 |
"Modified (format): / 23-09-2014 / 10:19:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
1031 |
!
|
|
1032 |
|
|
1033 |
suiteForRunAll
|
|
1034 |
|suite|
|
|
1035 |
|
|
1036 |
allTestCases isNil ifTrue:[
|
|
1037 |
self updateTestCases.
|
|
1038 |
].
|
|
1039 |
suite := TestSuite named:(self suiteNameFromClasses: self allTestCases).
|
|
1040 |
|
|
1041 |
allTestCases do:[:testCase |
|
|
1042 |
suite addTests:(self buildSuiteFromClass:testCase) tests
|
|
1043 |
].
|
|
1044 |
^suite
|
|
1045 |
|
|
1046 |
"Modified: / 04-03-2011 / 06:57:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
1047 |
"Modified: / 04-06-2012 / 19:01:48 / cg"
|
|
1048 |
!
|
|
1049 |
|
|
1050 |
suiteForRunFailed
|
|
1051 |
|suite numTests|
|
|
1052 |
|
|
1053 |
suite := TestSuite named:(self suiteNameFromClasses: self allTestCases).
|
|
1054 |
numTests := 0.
|
|
1055 |
|
|
1056 |
self allTestCases do:[:testCase |
|
|
1057 |
(self buildSuiteFromClass:testCase) tests do:[:eachTest |
|
|
1058 |
| sel cls |
|
|
1059 |
|
|
1060 |
sel := eachTest selector.
|
|
1061 |
cls := eachTest class.
|
|
1062 |
(cls testSelectorPassed:sel) ifFalse:[
|
|
1063 |
suite addTest:eachTest.
|
|
1064 |
numTests := numTests + 1.
|
|
1065 |
]
|
|
1066 |
]
|
|
1067 |
].
|
|
1068 |
numTests == 1 ifTrue:[
|
|
1069 |
suite name:(suite tests first selector)
|
|
1070 |
] ifFalse:[
|
|
1071 |
suite name:(suite tests size printString,' tests')
|
|
1072 |
].
|
|
1073 |
^suite
|
|
1074 |
|
|
1075 |
"Modified: / 04-03-2011 / 06:57:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
1076 |
"Created: / 04-06-2012 / 18:32:40 / cg"
|
|
1077 |
! !
|
|
1078 |
|
|
1079 |
!TestRunnerMini::SuiteAndResult class methodsFor:'instance creation'!
|
|
1080 |
|
|
1081 |
suite: suite result: result
|
|
1082 |
|
|
1083 |
^self new
|
|
1084 |
suite: suite;
|
|
1085 |
result: result.
|
|
1086 |
|
|
1087 |
"Modified: / 15-03-2010 / 15:27:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
1088 |
! !
|
|
1089 |
|
|
1090 |
!TestRunnerMini::SuiteAndResult methodsFor:'accessing'!
|
|
1091 |
|
|
1092 |
color
|
|
1093 |
|numTests numRun|
|
|
1094 |
|
|
1095 |
self testCount > 0 ifTrue:[
|
|
1096 |
result notNil ifTrue:[
|
|
1097 |
self hasErrors ifTrue:[^AbstractTestRunner errorColor].
|
|
1098 |
self hasFailures ifTrue:[^AbstractTestRunner failedColor].
|
|
1099 |
self hasPassed ifTrue:[
|
|
1100 |
numTests := suite tests size.
|
|
1101 |
numRun := result passedCount + result failureCount + result errorCount.
|
|
1102 |
numRun = numTests ifTrue:[
|
|
1103 |
^AbstractTestRunner passedColor
|
|
1104 |
]
|
|
1105 |
].
|
|
1106 |
]
|
|
1107 |
].
|
|
1108 |
^ AbstractTestRunner notRunColor
|
|
1109 |
|
|
1110 |
"Created: / 15-03-2010 / 15:24:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
1111 |
"Modified: / 23-09-2014 / 10:04:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
1112 |
!
|
|
1113 |
|
|
1114 |
info
|
|
1115 |
|numTests numRun|
|
|
1116 |
|
|
1117 |
result ifNil:[^''].
|
|
1118 |
|
|
1119 |
numTests := suite tests size.
|
|
1120 |
numRun := result passedCount + result failureCount + result errorCount.
|
|
1121 |
"/ (result passedCount + result failureCount + result errorCount) = 1 ifTrue:[^''].
|
|
1122 |
numRun == 0 ifTrue:[
|
|
1123 |
numTests == 1 ifTrue:[
|
|
1124 |
^'not run'
|
|
1125 |
].
|
|
1126 |
^'%1 tests, 0 run' bindWith: numTests
|
|
1127 |
].
|
|
1128 |
numRun < numTests ifTrue:[
|
|
1129 |
^'%1 tests, %2 run, %3 passed, %4 fail or error'
|
|
1130 |
bindWith: numTests
|
|
1131 |
with: numRun
|
|
1132 |
with: result passedCount
|
|
1133 |
with: (result failureCount+result errorCount)
|
|
1134 |
].
|
|
1135 |
|
|
1136 |
^'%1 tests, %2 passed, %3 failed, %4 errors'
|
|
1137 |
bindWith: numTests
|
|
1138 |
with: result passedCount
|
|
1139 |
with: result failureCount
|
|
1140 |
with: result errorCount
|
|
1141 |
|
|
1142 |
"Created: / 15-03-2010 / 20:23:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
1143 |
!
|
|
1144 |
|
|
1145 |
name
|
|
1146 |
|
|
1147 |
^suite name
|
|
1148 |
|
|
1149 |
"Created: / 15-03-2010 / 15:12:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
1150 |
!
|
|
1151 |
|
|
1152 |
result
|
|
1153 |
^ result
|
|
1154 |
!
|
|
1155 |
|
|
1156 |
result:aTestResult
|
|
1157 |
result := aTestResult.
|
|
1158 |
!
|
|
1159 |
|
|
1160 |
suite
|
|
1161 |
^ suite
|
|
1162 |
!
|
|
1163 |
|
|
1164 |
suite:aTestSuite
|
|
1165 |
suite := aTestSuite.
|
|
1166 |
!
|
|
1167 |
|
|
1168 |
suiteForRun
|
|
1169 |
|
|
1170 |
| suiteForRun |
|
|
1171 |
suiteForRun := suite class named: suite name.
|
|
1172 |
suiteForRun addTests:
|
|
1173 |
(suite tests collect:[:testCase|testCase class selector: testCase selector]).
|
|
1174 |
^suiteForRun
|
|
1175 |
|
|
1176 |
"Created: / 22-08-2011 / 09:56:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
1177 |
!
|
|
1178 |
|
|
1179 |
testCount
|
|
1180 |
|
|
1181 |
^suite tests size
|
|
1182 |
|
|
1183 |
"Created: / 15-03-2010 / 15:44:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
1184 |
! !
|
|
1185 |
|
|
1186 |
!TestRunnerMini::SuiteAndResult methodsFor:'queries'!
|
|
1187 |
|
|
1188 |
hasErrors
|
|
1189 |
|
|
1190 |
^result errorCount > 0
|
|
1191 |
|
|
1192 |
"Created: / 15-03-2010 / 15:21:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
1193 |
!
|
|
1194 |
|
|
1195 |
hasFailures
|
|
1196 |
|
|
1197 |
^result failureCount > 0
|
|
1198 |
|
|
1199 |
"Created: / 15-03-2010 / 15:21:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
1200 |
!
|
|
1201 |
|
|
1202 |
hasFailuresOrErrors
|
|
1203 |
|
|
1204 |
^self hasErrors or:[self hasFailures]
|
|
1205 |
|
|
1206 |
"Created: / 15-03-2010 / 15:45:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
1207 |
!
|
|
1208 |
|
|
1209 |
hasPassed
|
|
1210 |
|
|
1211 |
^result passedCount > 0
|
|
1212 |
|
|
1213 |
"Created: / 15-03-2010 / 22:06:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
1214 |
! !
|
|
1215 |
|
|
1216 |
!TestRunnerMini class methodsFor:'documentation'!
|
|
1217 |
|
|
1218 |
version
|
|
1219 |
^ '$Header: /cvs/stx/stx/libtool/Tools__TestRunnerMini.st,v 1.1 2014-09-23 09:29:37 vrany Exp $'
|
|
1220 |
!
|
|
1221 |
|
|
1222 |
version_CVS
|
|
1223 |
^ '$Header: /cvs/stx/stx/libtool/Tools__TestRunnerMini.st,v 1.1 2014-09-23 09:29:37 vrany Exp $'
|
|
1224 |
!
|
|
1225 |
|
|
1226 |
version_SVN
|
|
1227 |
^ '$Id: Tools__TestRunnerMini.st,v 1.1 2014-09-23 09:29:37 vrany Exp $'
|
|
1228 |
! !
|
|
1229 |
|