author | Claus Gittinger <cg@exept.de> |
Tue, 05 Jul 2011 19:33:32 +0200 | |
changeset 10178 | f5a662f12a4d |
parent 10175 | 7d8b7151c5a0 |
child 10184 | e5ea0ea47ea5 |
permissions | -rw-r--r-- |
9954 | 1 |
" |
10092 | 2 |
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague |
3 |
Copyright (c) 2009-2010 eXept Software AG |
|
9954 | 4 |
|
10092 | 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. |
|
9954 | 25 |
" |
26 |
"{ Package: 'stx:libtool' }" |
|
27 |
||
28 |
"{ NameSpace: Tools }" |
|
29 |
||
30 |
AbstractTestRunner subclass:#TestRunnerEmbedded |
|
31 |
instanceVariableNames:'runnerPanel selectedTestCases selectedClassesHolder |
|
32 |
selectedProtocolsHolder selectedMethodsHolder |
|
33 |
methodGeneratorHolder resultHolder resultInfoHolder |
|
10175 | 34 |
resultBackgroundColorHolder runningHolder progressHolder |
35 |
infoHolder' |
|
9954 | 36 |
classVariableNames:'' |
37 |
poolDictionaries:'' |
|
9956 | 38 |
category:'SUnit-UI' |
9954 | 39 |
! |
40 |
||
41 |
Object subclass:#SuiteAndResult |
|
42 |
instanceVariableNames:'suite result' |
|
43 |
classVariableNames:'' |
|
44 |
poolDictionaries:'' |
|
45 |
privateIn:TestRunnerEmbedded |
|
46 |
! |
|
47 |
||
48 |
!TestRunnerEmbedded class methodsFor:'documentation'! |
|
49 |
||
50 |
copyright |
|
51 |
" |
|
10092 | 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: |
|
9954 | 63 |
|
10092 | 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. |
|
9954 | 75 |
" |
10175 | 76 |
! |
77 |
||
78 |
documentation |
|
79 |
" |
|
80 |
a tiny runner to be embedded in a system browser |
|
81 |
" |
|
9954 | 82 |
! ! |
83 |
||
84 |
!TestRunnerEmbedded class methodsFor:'interface specs'! |
|
85 |
||
86 |
windowSpec |
|
87 |
"This resource specification was automatically generated |
|
88 |
by the UIPainter of ST/X." |
|
89 |
||
90 |
"Do not manually edit this!! If it is corrupted, |
|
91 |
the UIPainter may not be able to read the specification." |
|
92 |
||
93 |
" |
|
94 |
UIPainter new openOnClass:Tools::TestRunnerEmbedded andSelector:#windowSpec |
|
95 |
Tools::TestRunnerEmbedded new openInterface:#windowSpec |
|
96 |
Tools::TestRunnerEmbedded open |
|
97 |
" |
|
98 |
||
99 |
<resource: #canvas> |
|
100 |
||
101 |
^ |
|
102 |
#(FullSpec |
|
103 |
name: windowSpec |
|
104 |
window: |
|
105 |
(WindowSpec |
|
106 |
label: 'Test Runner Embedded' |
|
107 |
name: 'Test Runner Embedded' |
|
108 |
min: (Point 10 10) |
|
109 |
bounds: (Rectangle 0 0 350 50) |
|
110 |
) |
|
111 |
component: |
|
112 |
(SpecCollection |
|
113 |
collection: ( |
|
114 |
(VerticalPanelViewSpec |
|
115 |
name: 'Runners' |
|
116 |
layout: (LayoutFrame 5 0 0 0 -5 1 0 1) |
|
117 |
horizontalLayout: fit |
|
118 |
verticalLayout: topSpaceFit |
|
119 |
horizontalSpace: 0 |
|
120 |
verticalSpace: 5 |
|
121 |
elementsChangeSize: true |
|
122 |
component: |
|
123 |
(SpecCollection |
|
124 |
collection: ( |
|
125 |
(ViewSpec |
|
126 |
name: 'Runner' |
|
127 |
backgroundChannel: resultBackgroundColorAspect |
|
128 |
component: |
|
129 |
(SpecCollection |
|
130 |
collection: ( |
|
131 |
(HorizontalPanelViewSpec |
|
132 |
name: 'RunnerInnerBox' |
|
133 |
layout: (LayoutFrame 5 0 0 0 -5 1 0 1) |
|
134 |
horizontalLayout: rightSpaceFit |
|
135 |
verticalLayout: center |
|
136 |
horizontalSpace: 0 |
|
137 |
elementsChangeSize: true |
|
138 |
component: |
|
139 |
(SpecCollection |
|
140 |
collection: ( |
|
141 |
(ViewSpec |
|
142 |
name: 'RunnerInfoBox' |
|
143 |
backgroundChannel: resultBackgroundColorAspect |
|
144 |
component: |
|
145 |
(SpecCollection |
|
146 |
collection: ( |
|
147 |
(LabelSpec |
|
148 |
label: 'Run tests first!!' |
|
149 |
name: 'ResultName' |
|
150 |
layout: (LayoutFrame 0 0 0 0 0 1 -10 1) |
|
151 |
backgroundChannel: resultBackgroundColorAspect |
|
152 |
foregroundColor: (Color 100.0 100.0 100.0) |
|
153 |
translateLabel: true |
|
154 |
labelChannel: resultNameAspect |
|
155 |
adjust: left |
|
156 |
) |
|
157 |
(LabelSpec |
|
158 |
name: 'ResultInfo' |
|
159 |
layout: (LayoutFrame 0 0 -10 1 0 1 0 1) |
|
160 |
style: (FontDescription helvetica medium roman 8) |
|
161 |
backgroundChannel: resultBackgroundColorAspect |
|
162 |
foregroundColor: (Color 100.0 100.0 100.0) |
|
163 |
translateLabel: true |
|
164 |
labelChannel: resultInfoAspect |
|
165 |
adjust: left |
|
166 |
) |
|
167 |
(ViewSpec |
|
168 |
name: 'ProgressPanel' |
|
169 |
layout: (LayoutFrame 0 0 0 0 0 1 0 1) |
|
170 |
visibilityChannel: runningHolder |
|
171 |
backgroundChannel: resultBackgroundColorAspect |
|
172 |
component: |
|
173 |
(SpecCollection |
|
174 |
collection: ( |
|
175 |
(ProgressIndicatorSpec |
|
176 |
name: 'RunningProgress' |
|
177 |
layout: (LayoutFrame 5 0 -10 0.5 -5 1 10 0.5) |
|
178 |
model: progressHolder |
|
179 |
) |
|
180 |
) |
|
181 |
||
182 |
) |
|
183 |
) |
|
184 |
) |
|
185 |
||
186 |
) |
|
187 |
extent: (Point 151 30) |
|
188 |
) |
|
189 |
(ActionButtonSpec |
|
190 |
label: 'Debug' |
|
191 |
name: 'DebugButton' |
|
192 |
initiallyInvisible: true |
|
193 |
visibilityChannel: debugVisibleAspect |
|
194 |
translateLabel: true |
|
195 |
model: debug |
|
196 |
extent: (Point 60 25) |
|
197 |
) |
|
198 |
(ActionButtonSpec |
|
199 |
label: 'Run' |
|
200 |
name: 'Run' |
|
201 |
translateLabel: true |
|
202 |
model: run |
|
203 |
enableChannel: runEnabledHolder |
|
204 |
extent: (Point 60 25) |
|
205 |
) |
|
206 |
(ActionButtonSpec |
|
207 |
label: 'Run all' |
|
208 |
name: 'RunAll' |
|
209 |
translateLabel: true |
|
210 |
model: runAll |
|
211 |
enableChannel: runAllEnabledHolder |
|
212 |
extent: (Point 60 25) |
|
213 |
) |
|
214 |
) |
|
215 |
||
216 |
) |
|
217 |
postBuildCallback: postBuildRunnerPanel: |
|
218 |
) |
|
219 |
) |
|
220 |
||
221 |
) |
|
222 |
extent: (Point 340 40) |
|
223 |
) |
|
224 |
) |
|
225 |
||
226 |
) |
|
227 |
) |
|
228 |
) |
|
229 |
||
230 |
) |
|
231 |
) |
|
232 |
||
233 |
! ! |
|
234 |
||
235 |
!TestRunnerEmbedded class methodsFor:'plugIn spec'! |
|
236 |
||
237 |
aspectSelectors |
|
238 |
"This resource specification was automatically generated |
|
239 |
by the UIPainter of ST/X." |
|
240 |
||
241 |
"Do not manually edit this. If it is corrupted, |
|
242 |
the UIPainter may not be able to read the specification." |
|
243 |
||
244 |
"Return a description of exported aspects; |
|
245 |
these can be connected to aspects of an embedding application |
|
246 |
(if this app is embedded in a subCanvas)." |
|
247 |
||
248 |
^ #( |
|
249 |
#methodGeneratorHolder |
|
250 |
#selectedClassesHolder |
|
251 |
#selectedMethodsHolder |
|
252 |
#selectedProtocolsHolder |
|
253 |
). |
|
254 |
||
255 |
! ! |
|
256 |
||
257 |
!TestRunnerEmbedded methodsFor:'accessing'! |
|
258 |
||
10175 | 259 |
infoHolder:something |
260 |
"to show something in the browsers info area (near the bottom" |
|
261 |
||
262 |
infoHolder := something. |
|
263 |
||
264 |
"Created: / 05-07-2011 / 16:22:24 / cg" |
|
265 |
! |
|
266 |
||
9954 | 267 |
selectedTestMethods |
268 |
^ (self selectedMethodsHolder value ? #()) select: |
|
269 |
[:mthd | |
|
270 |
(self isTestCaseLike:mthd mclass) |
|
271 |
and:[ mthd mclass isTestSelector:mthd selector ] ] |
|
272 |
||
273 |
"Created: / 15-03-2010 / 13:21:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
274 |
"Modified: / 07-09-2010 / 08:30:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
275 |
! |
|
276 |
||
277 |
selectedTestMethodsFromProtocols:protocols |
|
278 |
|methods generator| |
|
279 |
||
280 |
methods := Set new. |
|
281 |
generator := self methodGeneratorHolder value. |
|
282 |
generator ifNotNil: |
|
283 |
[ generator do: |
|
284 |
[:cls :cat :sel :mthd | |
|
285 |
(mthd notNil |
|
286 |
and:[ (self isTestCaseLike:cls) and:[ cls isTestSelector:sel ] ]) |
|
287 |
ifTrue:[ methods add:mthd ] ] ] |
|
288 |
ifNil: |
|
289 |
[ selectedTestCases do: |
|
290 |
[:cls | |
|
291 |
cls methodsDo: |
|
292 |
[:mthd | |
|
293 |
((protocols includes:mthd category) |
|
294 |
and:[ cls isTestSelector:mthd selector ]) ifTrue:[ methods add:mthd ] ] ] ]. |
|
295 |
^ methods |
|
296 |
||
297 |
"Created: / 15-03-2010 / 19:50:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
298 |
"Modified: / 07-09-2010 / 08:29:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
299 |
! ! |
|
300 |
||
301 |
!TestRunnerEmbedded methodsFor:'actions'! |
|
302 |
||
303 |
debug |
|
304 |
||
305 |
| suiteAndResult | |
|
306 |
suiteAndResult := self resultHolder value. |
|
307 |
suiteAndResult suite tests size ~= 1 ifTrue:[^self breakPoint: #jv]. |
|
10178 | 308 |
[ |
309 |
suiteAndResult suite tests anyOne debug |
|
310 |
] fork |
|
9954 | 311 |
|
312 |
"Created: / 15-03-2010 / 15:43:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
313 |
"Modified: / 15-03-2010 / 20:09:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10178 | 314 |
"Modified: / 05-07-2011 / 19:05:31 / cg" |
9954 | 315 |
! |
316 |
||
317 |
run |
|
318 |
||
319 |
self run: resultHolder value suite |
|
320 |
||
321 |
"Created: / 10-03-2010 / 19:42:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
322 |
"Modified: / 15-03-2010 / 20:00:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
323 |
! |
|
324 |
||
10175 | 325 |
run:suite |
326 |
|process suiteAndResult| |
|
9954 | 327 |
|
10175 | 328 |
suite tests size == 0 ifTrue:[ |
329 |
^ self |
|
330 |
]. |
|
9954 | 331 |
|
10175 | 332 |
process := [ |
333 |
|result incr run| |
|
9954 | 334 |
|
10175 | 335 |
[ |
336 |
self progressHolder value:0. |
|
337 |
self runningHolder value:true. |
|
338 |
incr := 100 / suite tests size. |
|
339 |
run := 0. |
|
340 |
result := suite |
|
341 |
runBeforeEachDo:[:test :result | |
|
342 |
infoHolder notNil ifTrue:[ |
|
343 |
infoHolder value:('Running "%1-%2"...' |
|
344 |
bindWith:test name |
|
345 |
with:test getTestName allBold) |
|
346 |
] |
|
347 |
] |
|
348 |
afterEachDo:[:test :result | |
|
349 |
run := run + 1. |
|
350 |
self progressHolder value:(incr * run) rounded. |
|
351 |
infoHolder notNil ifTrue:[ |
|
352 |
infoHolder value:('Done.') |
|
353 |
] |
|
354 |
]. |
|
355 |
suiteAndResult := SuiteAndResult suite:suite result:result. |
|
356 |
] ensure:[ |
|
357 |
self resultHolder value:suiteAndResult. |
|
358 |
self runningHolder value:false. |
|
359 |
] |
|
360 |
] newProcess. |
|
9954 | 361 |
process resume. |
362 |
||
363 |
"Created: / 11-03-2010 / 10:22:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
364 |
"Modified: / 06-09-2010 / 21:48:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10175 | 365 |
"Modified: / 05-07-2011 / 17:44:38 / cg" |
9954 | 366 |
! |
367 |
||
368 |
runAll |
|
369 |
||
370 |
self run: self suiteForRunAll. |
|
371 |
||
372 |
"Created: / 10-03-2010 / 19:42:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
373 |
"Modified: / 15-03-2010 / 13:12:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10178 | 374 |
! |
375 |
||
376 |
runWithDebug |
|
377 |
"/ cg: I really do not want to run them twice to get a debugger |
|
378 |
"/ - I want to run them either with a debugger coming right away, or not. |
|
379 |
||
380 |
| suiteAndResult suite result| |
|
381 |
||
382 |
suiteAndResult := self resultHolder value. |
|
383 |
suite := suiteAndResult suite. |
|
384 |
result := suiteAndResult result. |
|
385 |
||
386 |
suite tests do:[:each | |
|
387 |
|errorHappened failureHappened cls| |
|
388 |
||
389 |
errorHappened := failureHappened := false. |
|
390 |
GenericException |
|
391 |
handle:[:ex | |
|
392 |
(HaltInterrupt accepts:ex signal) ifFalse:[ |
|
393 |
ex signal == NoHandlerError ifFalse:[ |
|
394 |
(TestFailure accepts:ex signal) ifTrue:[ |
|
395 |
failureHappened := true |
|
396 |
] ifFalse:[ |
|
397 |
errorHappened := true. |
|
398 |
]. |
|
399 |
] |
|
400 |
]. |
|
401 |
ex reject. |
|
402 |
] |
|
403 |
do:[ |
|
404 |
infoHolder notNil ifTrue:[ |
|
405 |
infoHolder value:('Running "%1-%2"...' |
|
406 |
bindWith:each name |
|
407 |
with:each getTestName allBold) |
|
408 |
]. |
|
409 |
each debug. |
|
410 |
infoHolder notNil ifTrue:[ |
|
411 |
infoHolder value:('Done.') |
|
412 |
] |
|
413 |
]. |
|
414 |
||
415 |
result failures remove:each ifAbsent:[]. |
|
416 |
result passed remove:each ifAbsent:[]. |
|
417 |
result errors remove:each ifAbsent:[]. |
|
418 |
||
419 |
failureHappened ifTrue:[ |
|
420 |
each class rememberErrorTest:each selector. |
|
421 |
result errors add:each. |
|
422 |
] ifFalse:[ |
|
423 |
errorHappened ifTrue:[ |
|
424 |
each class rememberFailedTest:each selector. |
|
425 |
result failures add:each. |
|
426 |
] ifFalse:[ |
|
427 |
each class rememberPassedTest:each selector. |
|
428 |
result passed add:each. |
|
429 |
] |
|
430 |
] |
|
431 |
] |
|
432 |
||
433 |
"/ suiteAndResult suite tests size ~= 1 ifTrue:[^self breakPoint: #jv]. |
|
434 |
"/ [suiteAndResult suite tests anyOne debug] fork |
|
435 |
||
436 |
"Modified: / 15-03-2010 / 20:09:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
437 |
"Created: / 05-07-2011 / 18:45:43 / cg" |
|
9954 | 438 |
! ! |
439 |
||
440 |
!TestRunnerEmbedded methodsFor:'aspects'! |
|
441 |
||
442 |
debugVisibleAspect |
|
443 |
||
444 |
^BlockValue |
|
445 |
with: |
|
446 |
[:model| |
|
447 |
model |
|
448 |
ifNil:[false] |
|
449 |
ifNotNil:[model testCount == 1 and:[model hasFailuresOrErrors]]] |
|
450 |
argument: |
|
451 |
self resultHolder |
|
452 |
||
453 |
"Created: / 15-03-2010 / 15:40:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
454 |
! |
|
455 |
||
456 |
methodGeneratorHolder |
|
457 |
"return/create the 'methodGeneratorHolder' value holder (automatically generated)" |
|
458 |
||
459 |
methodGeneratorHolder isNil ifTrue:[ |
|
460 |
methodGeneratorHolder := ValueHolder new. |
|
461 |
methodGeneratorHolder addDependent:self. |
|
462 |
]. |
|
463 |
^ methodGeneratorHolder |
|
464 |
! |
|
465 |
||
466 |
methodGeneratorHolder:something |
|
467 |
"set the 'methodGeneratorHolder' value holder (automatically generated)" |
|
468 |
||
469 |
|oldValue newValue| |
|
470 |
||
471 |
methodGeneratorHolder notNil ifTrue:[ |
|
472 |
oldValue := methodGeneratorHolder value. |
|
473 |
methodGeneratorHolder removeDependent:self. |
|
474 |
]. |
|
475 |
methodGeneratorHolder := something. |
|
476 |
methodGeneratorHolder notNil ifTrue:[ |
|
477 |
methodGeneratorHolder addDependent:self. |
|
478 |
]. |
|
479 |
newValue := methodGeneratorHolder value. |
|
480 |
oldValue ~~ newValue ifTrue:[ |
|
481 |
self update:#value with:newValue from:methodGeneratorHolder. |
|
482 |
]. |
|
483 |
! |
|
484 |
||
485 |
progressHolder |
|
486 |
"return/create the 'progressHolder' value holder (automatically generated)" |
|
487 |
||
488 |
progressHolder isNil ifTrue:[ |
|
489 |
progressHolder := ValueHolder new. |
|
490 |
]. |
|
491 |
^ progressHolder |
|
492 |
! |
|
493 |
||
494 |
resultBackgroundColorAspect |
|
495 |
<resource: #uiAspect> |
|
496 |
resultBackgroundColorHolder isNil ifTrue:[ |
|
10165
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
497 |
resultBackgroundColorHolder := BlockValue |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
498 |
with:[:result :running | |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
499 |
running ifTrue:[ |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
500 |
self class currentlyRunningColor "/ View defaultBackgroundColor |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
501 |
] ifFalse:[ |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
502 |
result ifNil:[ self class notRunColor ] ifNotNil:[ result color ] |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
503 |
] |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
504 |
] |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
505 |
argument:self resultHolder |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
506 |
argument:self runningHolder. |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
507 |
resultBackgroundColorHolder |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
508 |
onChangeEvaluate:[ |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
509 |
runnerPanel |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
510 |
ifNotNil:[ runnerPanel backgroundColor:resultBackgroundColorHolder value ] |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
511 |
]. |
9954 | 512 |
]. |
513 |
^ resultBackgroundColorHolder. |
|
514 |
||
515 |
"Created: / 15-03-2010 / 15:22:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
516 |
"Modified: / 15-03-2010 / 21:02:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10165
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
517 |
"Modified (comment): / 05-07-2011 / 14:13:30 / cg" |
9954 | 518 |
! |
519 |
||
520 |
resultHolder |
|
521 |
"return/create the 'resultHolder' value holder (automatically generated)" |
|
522 |
||
523 |
resultHolder isNil ifTrue:[ |
|
524 |
resultHolder := ValueHolder new. |
|
525 |
]. |
|
526 |
^ resultHolder |
|
527 |
! |
|
528 |
||
529 |
resultInfoAspect |
|
530 |
||
531 |
^BlockValue |
|
532 |
with: |
|
533 |
[:model| |
|
534 |
model |
|
535 |
ifNil:[''] |
|
536 |
ifNotNil:[model info]] |
|
537 |
argument: |
|
538 |
self resultHolder |
|
539 |
||
540 |
"Created: / 15-03-2010 / 20:22:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
541 |
! |
|
542 |
||
543 |
resultNameAspect |
|
544 |
||
545 |
^BlockValue |
|
546 |
with: |
|
547 |
[:model| |
|
548 |
model |
|
549 |
ifNil:['Run the tests!!'] |
|
550 |
ifNotNil:[model name]] |
|
551 |
argument: |
|
552 |
self resultHolder |
|
553 |
||
554 |
"Created: / 15-03-2010 / 14:57:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
555 |
"Modified: / 15-03-2010 / 20:17:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
556 |
! |
|
557 |
||
558 |
runAllEnabledHolder |
|
559 |
||
560 |
^true |
|
561 |
||
562 |
"Created: / 07-09-2010 / 09:15:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
563 |
! |
|
564 |
||
565 |
runEnabledHolder |
|
566 |
||
567 |
^BlockValue |
|
568 |
with: |
|
569 |
[:resultHolder | | result | |
|
570 |
(result := resultHolder value) notNil and:[result testCount > 0 ]] |
|
571 |
argument: self resultHolder |
|
572 |
||
573 |
"Created: / 07-09-2010 / 09:15:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
574 |
! |
|
575 |
||
576 |
runningHolder |
|
577 |
"return/create the 'runningHolder' value holder (automatically generated)" |
|
578 |
||
579 |
runningHolder isNil ifTrue:[ |
|
580 |
runningHolder := ValueHolder with: false. |
|
581 |
]. |
|
582 |
^ runningHolder |
|
583 |
||
584 |
"Modified: / 15-03-2010 / 20:29:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
585 |
! |
|
586 |
||
587 |
selectedClassesHolder |
|
588 |
"return/create the 'selectedClassesHolder' value holder (automatically generated)" |
|
589 |
||
590 |
selectedClassesHolder isNil ifTrue:[ |
|
591 |
selectedClassesHolder := ValueHolder new. |
|
592 |
selectedClassesHolder addDependent:self. |
|
593 |
]. |
|
594 |
^ selectedClassesHolder |
|
595 |
! |
|
596 |
||
597 |
selectedClassesHolder:something |
|
598 |
"set the 'selectedClassesHolder' value holder (automatically generated)" |
|
599 |
||
600 |
|oldValue newValue| |
|
601 |
||
602 |
selectedClassesHolder notNil ifTrue:[ |
|
603 |
oldValue := selectedClassesHolder value. |
|
604 |
selectedClassesHolder removeDependent:self. |
|
605 |
]. |
|
606 |
selectedClassesHolder := something. |
|
607 |
selectedClassesHolder notNil ifTrue:[ |
|
608 |
selectedClassesHolder addDependent:self. |
|
609 |
]. |
|
610 |
newValue := selectedClassesHolder value. |
|
611 |
oldValue ~~ newValue ifTrue:[ |
|
612 |
self update:#value with:newValue from:selectedClassesHolder. |
|
613 |
]. |
|
614 |
! |
|
615 |
||
616 |
selectedMethodsHolder |
|
617 |
"return/create the 'selectedMethodsHolder' value holder (automatically generated)" |
|
618 |
||
619 |
selectedMethodsHolder isNil ifTrue:[ |
|
620 |
selectedMethodsHolder := ValueHolder new. |
|
621 |
selectedMethodsHolder addDependent:self. |
|
622 |
]. |
|
623 |
^ selectedMethodsHolder |
|
624 |
! |
|
625 |
||
626 |
selectedMethodsHolder:something |
|
627 |
"set the 'selectedMethodsHolder' value holder (automatically generated)" |
|
628 |
||
629 |
|oldValue newValue| |
|
630 |
||
631 |
selectedMethodsHolder notNil ifTrue:[ |
|
632 |
oldValue := selectedMethodsHolder value. |
|
633 |
selectedMethodsHolder removeDependent:self. |
|
634 |
]. |
|
635 |
selectedMethodsHolder := something. |
|
636 |
selectedMethodsHolder notNil ifTrue:[ |
|
637 |
selectedMethodsHolder addDependent:self. |
|
638 |
]. |
|
639 |
newValue := selectedMethodsHolder value. |
|
640 |
oldValue ~~ newValue ifTrue:[ |
|
641 |
self update:#value with:newValue from:selectedMethodsHolder. |
|
642 |
]. |
|
643 |
! |
|
644 |
||
645 |
selectedProtocolsHolder |
|
646 |
"return/create the 'selectedProtocolsHolder' value holder (automatically generated)" |
|
647 |
||
648 |
selectedProtocolsHolder isNil ifTrue:[ |
|
649 |
selectedProtocolsHolder := ValueHolder new. |
|
650 |
selectedProtocolsHolder addDependent:self. |
|
651 |
]. |
|
652 |
^ selectedProtocolsHolder |
|
653 |
! |
|
654 |
||
655 |
selectedProtocolsHolder:something |
|
656 |
"set the 'selectedProtocolsHolder' value holder (automatically generated)" |
|
657 |
||
658 |
|oldValue newValue| |
|
659 |
||
660 |
selectedProtocolsHolder notNil ifTrue:[ |
|
661 |
oldValue := selectedProtocolsHolder value. |
|
662 |
selectedProtocolsHolder removeDependent:self. |
|
663 |
]. |
|
664 |
selectedProtocolsHolder := something. |
|
665 |
selectedProtocolsHolder notNil ifTrue:[ |
|
666 |
selectedProtocolsHolder addDependent:self. |
|
667 |
]. |
|
668 |
newValue := selectedProtocolsHolder value. |
|
669 |
oldValue ~~ newValue ifTrue:[ |
|
670 |
self update:#value with:newValue from:selectedProtocolsHolder. |
|
671 |
]. |
|
672 |
! ! |
|
673 |
||
674 |
!TestRunnerEmbedded methodsFor:'change & update'! |
|
675 |
||
676 |
update:aspect with:param from: sender |
|
677 |
"Invoked when an object that I depend upon sends a change notification." |
|
678 |
||
679 |
sender == selectedClassesHolder ifTrue:[ |
|
680 |
self |
|
681 |
updateTestCases; |
|
682 |
updateTestSuiteAndResult; |
|
683 |
updateVisibility. |
|
684 |
^ self. |
|
685 |
]. |
|
686 |
sender == selectedProtocolsHolder ifTrue:[ |
|
687 |
self updateTestSuiteAndResult. |
|
688 |
^self |
|
689 |
]. |
|
690 |
||
691 |
sender == selectedMethodsHolder ifTrue:[ |
|
692 |
self updateTestSuiteAndResult. |
|
693 |
^self |
|
694 |
]. |
|
695 |
sender == methodGeneratorHolder ifTrue:[ |
|
696 |
self updateTestSuiteAndResult. |
|
697 |
^self |
|
698 |
]. |
|
699 |
||
700 |
||
701 |
||
702 |
super update:aspect with:param from: sender |
|
703 |
||
704 |
"Modified: / 07-09-2010 / 08:18:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
705 |
! |
|
706 |
||
707 |
updateTestCases |
|
708 |
selectedTestCases := (self selectedClassesHolder value |
|
709 |
select:[:cls | self isTestCaseLike:cls ]). |
|
710 |
selectedTestCases := selectedTestCases isEmpty |
|
711 |
ifTrue:[ nil ] |
|
712 |
ifFalse:[ selectedTestCases asArray ] |
|
713 |
||
714 |
"Created: / 11-03-2010 / 10:31:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
715 |
"Modified: / 15-03-2010 / 20:53:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
716 |
! |
|
717 |
||
718 |
updateTestSuiteAndResult |
|
719 |
||
720 |
| suite suiteAndResult | |
|
721 |
self runningHolder value ifTrue:[^self]. |
|
722 |
selectedTestCases ifNil:[^self]. |
|
723 |
suiteAndResult := SuiteAndResult |
|
724 |
suite: (suite := self suiteForRun) |
|
725 |
result: (self resultForSuite: suite). |
|
726 |
self resultHolder value: suiteAndResult. |
|
727 |
||
728 |
"Created: / 15-03-2010 / 19:41:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
729 |
"Modified: / 15-03-2010 / 20:55:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
730 |
! |
|
731 |
||
732 |
updateVisibility |
|
733 |
||
734 |
self hasTestCaseSelected |
|
735 |
ifTrue:[self show] |
|
736 |
ifFalse:[self hide] |
|
737 |
||
738 |
"Created: / 11-03-2010 / 09:02:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
739 |
! ! |
|
740 |
||
741 |
!TestRunnerEmbedded methodsFor:'hooks'! |
|
742 |
||
743 |
postBuildRunnerPanel: aView |
|
744 |
||
745 |
runnerPanel := aView. |
|
746 |
runnerPanel backgroundColor: self resultBackgroundColorAspect value |
|
747 |
||
748 |
"Created: / 15-03-2010 / 14:26:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
749 |
! ! |
|
750 |
||
751 |
!TestRunnerEmbedded methodsFor:'private'! |
|
752 |
||
753 |
hide |
|
754 |
||
755 |
self visibility: false height: 0 |
|
756 |
||
757 |
"Created: / 11-03-2010 / 09:07:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
758 |
! |
|
759 |
||
760 |
isTestCaseLike:cls |
|
761 |
||
762 |
^(super isTestCaseLike: cls) and: |
|
763 |
[(cls askFor: #isAbstract) not] |
|
764 |
||
765 |
"Modified: / 04-03-2011 / 06:54:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
766 |
! |
|
767 |
||
768 |
show |
|
769 |
||
770 |
self visibility: true height: 50 |
|
771 |
||
772 |
"Created: / 11-03-2010 / 09:07:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
773 |
! |
|
774 |
||
775 |
visibility: visibility height: height |
|
776 |
| container list h | |
|
777 |
(container := self window container) ifNil:[^self]. |
|
778 |
h := visibility ifFalse:[0] ifTrue:[height]. |
|
779 |
||
780 |
container isVisible == visibility ifFalse: |
|
781 |
[container isVisible: visibility]. |
|
782 |
||
783 |
||
784 |
list := container container subViews first. |
|
785 |
||
786 |
(list layout bottomOffset ~= height negated) ifTrue: |
|
787 |
[list layout: |
|
788 |
(list layout bottomOffset: height negated; yourself)]. |
|
789 |
||
790 |
"Created: / 11-03-2010 / 09:51:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
791 |
! ! |
|
792 |
||
793 |
!TestRunnerEmbedded methodsFor:'queries'! |
|
794 |
||
795 |
hasTestCaseSelected |
|
796 |
||
797 |
^selectedTestCases isNilOrEmptyCollection not |
|
798 |
||
799 |
"Created: / 11-03-2010 / 09:06:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
800 |
"Modified: / 15-03-2010 / 20:54:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
801 |
! ! |
|
802 |
||
803 |
!TestRunnerEmbedded methodsFor:'utilities'! |
|
804 |
||
805 |
resultForSuite: suite |
|
806 |
||
807 |
| result | |
|
808 |
result := TestResult new. |
|
809 |
suite tests do: |
|
810 |
[:test| |
|
811 |
(test class testSelectorPassed: test selector) |
|
812 |
ifTrue: |
|
813 |
[result passed add: test] |
|
814 |
ifFalse: |
|
815 |
[(test class testSelectorError: test selector) |
|
816 |
ifTrue: |
|
817 |
[result errors add: test] |
|
818 |
ifFalse: |
|
819 |
[(test class testSelectorFailed: test selector) |
|
820 |
ifTrue: |
|
821 |
[result failures add: test]]]]. |
|
822 |
^result |
|
823 |
||
824 |
"Created: / 15-03-2010 / 19:46:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
825 |
! |
|
826 |
||
827 |
suiteForRun |
|
828 |
| methods protocols suite | |
|
829 |
(methods := selectedMethodsHolder value) isNilOrEmptyCollection ifFalse: |
|
830 |
[suite := TestSuite named: (self suiteNameFromMethods: methods). |
|
831 |
self selectedTestMethods do: |
|
832 |
[:mthd| | selector | |
|
833 |
suite addTest: (mthd mclass asTestCase selector: mthd selector)]. |
|
834 |
^suite]. |
|
835 |
||
836 |
(protocols := selectedProtocolsHolder value) isNilOrEmptyCollection ifFalse: |
|
837 |
[suite := TestSuite named: (self suiteNameFromProtocols: protocols). |
|
838 |
(self selectedTestMethodsFromProtocols: protocols) do: |
|
839 |
[:mthd| | selector | |
|
840 |
suite addTest: (mthd mclass asTestCase selector: mthd selector)]. |
|
841 |
^suite]. |
|
842 |
^self suiteForRunAll |
|
843 |
||
844 |
"Created: / 15-03-2010 / 13:13:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
845 |
"Modified: / 04-03-2011 / 08:24:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
846 |
! |
|
847 |
||
848 |
suiteForRunAll |
|
849 |
|suite| |
|
850 |
suite := TestSuite named:(self suiteNameFromClasses: selectedTestCases). |
|
851 |
selectedTestCases |
|
852 |
do:[:testCase | suite addTests:(self buildSuiteFromClass:testCase) tests]. |
|
853 |
^suite |
|
854 |
||
855 |
"Modified: / 04-03-2011 / 06:57:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
856 |
! ! |
|
857 |
||
858 |
!TestRunnerEmbedded::SuiteAndResult class methodsFor:'instance creation'! |
|
859 |
||
860 |
suite: suite result: result |
|
861 |
||
862 |
^self new |
|
863 |
suite: suite; |
|
864 |
result: result. |
|
865 |
||
866 |
"Modified: / 15-03-2010 / 15:27:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
867 |
! ! |
|
868 |
||
869 |
!TestRunnerEmbedded::SuiteAndResult methodsFor:'accessing'! |
|
870 |
||
871 |
color |
|
872 |
||
873 |
self testCount == 0 ifTrue: |
|
874 |
[^TestRunnerEmbedded notRunColor]. |
|
875 |
||
876 |
result ifNil:[^TestRunnerEmbedded notRunColor]. |
|
877 |
self hasErrors ifTrue:[^TestRunnerEmbedded errorColor]. |
|
878 |
self hasFailures ifTrue:[^TestRunnerEmbedded failedColor]. |
|
879 |
self hasPassed ifTrue:[^TestRunnerEmbedded passedColor]. |
|
880 |
^TestRunnerEmbedded notRunColor |
|
881 |
||
882 |
"Created: / 15-03-2010 / 15:24:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
883 |
"Modified: / 07-09-2010 / 08:25:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
884 |
! |
|
885 |
||
886 |
info |
|
887 |
||
888 |
result ifNil:[^'']. |
|
889 |
(result passedCount + result failureCount + result errorCount) = 1 ifTrue:[^'']. |
|
890 |
^'%1 tests, %2 passed, %3 failed, %4 errors' |
|
891 |
bindWith: suite tests size |
|
892 |
with: result passedCount |
|
893 |
with: result failureCount |
|
894 |
with: result errorCount |
|
895 |
||
896 |
"Created: / 15-03-2010 / 20:23:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
897 |
! |
|
898 |
||
899 |
name |
|
900 |
||
901 |
^suite name |
|
902 |
||
903 |
"Created: / 15-03-2010 / 15:12:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
904 |
! |
|
905 |
||
906 |
result |
|
907 |
^ result |
|
908 |
! |
|
909 |
||
910 |
result:aTestResult |
|
911 |
result := aTestResult. |
|
912 |
! |
|
913 |
||
914 |
suite |
|
915 |
^ suite |
|
916 |
! |
|
917 |
||
918 |
suite:aTestSuite |
|
919 |
suite := aTestSuite. |
|
920 |
! |
|
921 |
||
922 |
testCount |
|
923 |
||
924 |
^suite tests size |
|
925 |
||
926 |
"Created: / 15-03-2010 / 15:44:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
927 |
! ! |
|
928 |
||
929 |
!TestRunnerEmbedded::SuiteAndResult methodsFor:'queries'! |
|
930 |
||
931 |
hasErrors |
|
932 |
||
933 |
^result errorCount > 0 |
|
934 |
||
935 |
"Created: / 15-03-2010 / 15:21:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
936 |
! |
|
937 |
||
938 |
hasFailures |
|
939 |
||
940 |
^result failureCount > 0 |
|
941 |
||
942 |
"Created: / 15-03-2010 / 15:21:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
943 |
! |
|
944 |
||
945 |
hasFailuresOrErrors |
|
946 |
||
947 |
^self hasErrors or:[self hasFailures] |
|
948 |
||
949 |
"Created: / 15-03-2010 / 15:45:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
950 |
! |
|
951 |
||
952 |
hasPassed |
|
953 |
||
954 |
^result passedCount > 0 |
|
955 |
||
956 |
"Created: / 15-03-2010 / 22:06:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
957 |
! ! |
|
958 |
||
959 |
!TestRunnerEmbedded class methodsFor:'documentation'! |
|
960 |
||
961 |
version_CVS |
|
10178 | 962 |
^ '$Header: /cvs/stx/stx/libtool/Tools__TestRunnerEmbedded.st,v 1.6 2011-07-05 17:33:32 cg Exp $' |
9954 | 963 |
! |
964 |
||
965 |
version_SVN |
|
966 |
^ '§Id: Tools__TestRunnerEmbedded.st 7681 2011-03-04 11:30:02Z vranyj1 §' |
|
967 |
! ! |