author | vrany |
Thu, 07 Jul 2011 12:40:45 +0200 | |
changeset 10243 | f8b2067424ed |
parent 10201 | abe808684440 |
child 10374 | 884c2b9cb74c |
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 |
||
10243
f8b2067424ed
changed: #debug: bug fix: if the test pass when debugging, update the UI
vrany
parents:
10201
diff
changeset
|
305 |
| suiteAndResult suite test result | |
9954 | 306 |
suiteAndResult := self resultHolder value. |
10243
f8b2067424ed
changed: #debug: bug fix: if the test pass when debugging, update the UI
vrany
parents:
10201
diff
changeset
|
307 |
suite := suiteAndResult suite. |
f8b2067424ed
changed: #debug: bug fix: if the test pass when debugging, update the UI
vrany
parents:
10201
diff
changeset
|
308 |
suite tests size ~= 1 ifTrue:[^self breakPoint: #jv]. |
f8b2067424ed
changed: #debug: bug fix: if the test pass when debugging, update the UI
vrany
parents:
10201
diff
changeset
|
309 |
test := suiteAndResult suite tests anyOne. |
10178 | 310 |
[ |
10243
f8b2067424ed
changed: #debug: bug fix: if the test pass when debugging, update the UI
vrany
parents:
10201
diff
changeset
|
311 |
test debug. |
f8b2067424ed
changed: #debug: bug fix: if the test pass when debugging, update the UI
vrany
parents:
10201
diff
changeset
|
312 |
(test class testSelectorPassed:test selector) ifTrue:[ |
f8b2067424ed
changed: #debug: bug fix: if the test pass when debugging, update the UI
vrany
parents:
10201
diff
changeset
|
313 |
result := TestResult new. |
f8b2067424ed
changed: #debug: bug fix: if the test pass when debugging, update the UI
vrany
parents:
10201
diff
changeset
|
314 |
result passed add: test. |
f8b2067424ed
changed: #debug: bug fix: if the test pass when debugging, update the UI
vrany
parents:
10201
diff
changeset
|
315 |
suiteAndResult := SuiteAndResult suite: suite result: result. |
f8b2067424ed
changed: #debug: bug fix: if the test pass when debugging, update the UI
vrany
parents:
10201
diff
changeset
|
316 |
self resultHolder value:suiteAndResult. |
f8b2067424ed
changed: #debug: bug fix: if the test pass when debugging, update the UI
vrany
parents:
10201
diff
changeset
|
317 |
]. |
10178 | 318 |
] fork |
9954 | 319 |
|
320 |
"Created: / 15-03-2010 / 15:43:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
321 |
"Modified: / 15-03-2010 / 20:09:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10178 | 322 |
"Modified: / 05-07-2011 / 19:05:31 / cg" |
10243
f8b2067424ed
changed: #debug: bug fix: if the test pass when debugging, update the UI
vrany
parents:
10201
diff
changeset
|
323 |
"Modified: / 07-07-2011 / 11:33:48 / Jan Vrany <jan.vrant@fit.cvut,cz>" |
9954 | 324 |
! |
325 |
||
326 |
run |
|
327 |
||
328 |
self run: resultHolder value suite |
|
329 |
||
330 |
"Created: / 10-03-2010 / 19:42:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
331 |
"Modified: / 15-03-2010 / 20:00:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
332 |
! |
|
333 |
||
10175 | 334 |
run:suite |
10201 | 335 |
|process suiteAndResult numTests| |
9954 | 336 |
|
10201 | 337 |
numTests := suite tests size. |
338 |
numTests == 0 ifTrue:[ |
|
10175 | 339 |
^ self |
340 |
]. |
|
9954 | 341 |
|
10175 | 342 |
process := [ |
343 |
|result incr run| |
|
9954 | 344 |
|
10175 | 345 |
[ |
346 |
self progressHolder value:0. |
|
347 |
self runningHolder value:true. |
|
10201 | 348 |
incr := 100 / numTests. |
10175 | 349 |
run := 0. |
350 |
result := suite |
|
351 |
runBeforeEachDo:[:test :result | |
|
352 |
infoHolder notNil ifTrue:[ |
|
353 |
infoHolder value:('Running "%1-%2"...' |
|
354 |
bindWith:test name |
|
355 |
with:test getTestName allBold) |
|
356 |
] |
|
357 |
] |
|
358 |
afterEachDo:[:test :result | |
|
359 |
run := run + 1. |
|
10184 | 360 |
self progressHolder value:(incr * run) truncated "rounded". |
10175 | 361 |
infoHolder notNil ifTrue:[ |
362 |
infoHolder value:('Done.') |
|
363 |
] |
|
364 |
]. |
|
365 |
suiteAndResult := SuiteAndResult suite:suite result:result. |
|
366 |
] ensure:[ |
|
367 |
self resultHolder value:suiteAndResult. |
|
368 |
self runningHolder value:false. |
|
369 |
] |
|
370 |
] newProcess. |
|
9954 | 371 |
process resume. |
372 |
||
373 |
"Created: / 11-03-2010 / 10:22:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
374 |
"Modified: / 06-09-2010 / 21:48:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10201 | 375 |
"Modified: / 06-07-2011 / 14:28:02 / cg" |
9954 | 376 |
! |
377 |
||
378 |
runAll |
|
379 |
||
380 |
self run: self suiteForRunAll. |
|
381 |
||
382 |
"Created: / 10-03-2010 / 19:42:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
383 |
"Modified: / 15-03-2010 / 13:12:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10178 | 384 |
! |
385 |
||
386 |
runWithDebug |
|
387 |
"/ cg: I really do not want to run them twice to get a debugger |
|
388 |
"/ - I want to run them either with a debugger coming right away, or not. |
|
389 |
||
390 |
| suiteAndResult suite result| |
|
391 |
||
392 |
suiteAndResult := self resultHolder value. |
|
393 |
suite := suiteAndResult suite. |
|
394 |
result := suiteAndResult result. |
|
395 |
||
396 |
suite tests do:[:each | |
|
397 |
|errorHappened failureHappened cls| |
|
398 |
||
399 |
errorHappened := failureHappened := false. |
|
400 |
GenericException |
|
401 |
handle:[:ex | |
|
402 |
(HaltInterrupt accepts:ex signal) ifFalse:[ |
|
403 |
ex signal == NoHandlerError ifFalse:[ |
|
404 |
(TestFailure accepts:ex signal) ifTrue:[ |
|
405 |
failureHappened := true |
|
406 |
] ifFalse:[ |
|
407 |
errorHappened := true. |
|
408 |
]. |
|
409 |
] |
|
410 |
]. |
|
411 |
ex reject. |
|
412 |
] |
|
413 |
do:[ |
|
414 |
infoHolder notNil ifTrue:[ |
|
415 |
infoHolder value:('Running "%1-%2"...' |
|
416 |
bindWith:each name |
|
417 |
with:each getTestName allBold) |
|
418 |
]. |
|
419 |
each debug. |
|
420 |
infoHolder notNil ifTrue:[ |
|
421 |
infoHolder value:('Done.') |
|
422 |
] |
|
423 |
]. |
|
424 |
||
425 |
result failures remove:each ifAbsent:[]. |
|
426 |
result passed remove:each ifAbsent:[]. |
|
427 |
result errors remove:each ifAbsent:[]. |
|
428 |
||
429 |
failureHappened ifTrue:[ |
|
430 |
each class rememberErrorTest:each selector. |
|
431 |
result errors add:each. |
|
432 |
] ifFalse:[ |
|
433 |
errorHappened ifTrue:[ |
|
434 |
each class rememberFailedTest:each selector. |
|
435 |
result failures add:each. |
|
436 |
] ifFalse:[ |
|
437 |
each class rememberPassedTest:each selector. |
|
438 |
result passed add:each. |
|
439 |
] |
|
440 |
] |
|
441 |
] |
|
442 |
||
443 |
"/ suiteAndResult suite tests size ~= 1 ifTrue:[^self breakPoint: #jv]. |
|
444 |
"/ [suiteAndResult suite tests anyOne debug] fork |
|
445 |
||
446 |
"Modified: / 15-03-2010 / 20:09:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
447 |
"Created: / 05-07-2011 / 18:45:43 / cg" |
|
9954 | 448 |
! ! |
449 |
||
450 |
!TestRunnerEmbedded methodsFor:'aspects'! |
|
451 |
||
452 |
debugVisibleAspect |
|
453 |
||
454 |
^BlockValue |
|
455 |
with: |
|
456 |
[:model| |
|
457 |
model |
|
458 |
ifNil:[false] |
|
459 |
ifNotNil:[model testCount == 1 and:[model hasFailuresOrErrors]]] |
|
460 |
argument: |
|
461 |
self resultHolder |
|
462 |
||
463 |
"Created: / 15-03-2010 / 15:40:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
464 |
! |
|
465 |
||
466 |
methodGeneratorHolder |
|
467 |
"return/create the 'methodGeneratorHolder' value holder (automatically generated)" |
|
468 |
||
469 |
methodGeneratorHolder isNil ifTrue:[ |
|
470 |
methodGeneratorHolder := ValueHolder new. |
|
471 |
methodGeneratorHolder addDependent:self. |
|
472 |
]. |
|
473 |
^ methodGeneratorHolder |
|
474 |
! |
|
475 |
||
476 |
methodGeneratorHolder:something |
|
477 |
"set the 'methodGeneratorHolder' value holder (automatically generated)" |
|
478 |
||
479 |
|oldValue newValue| |
|
480 |
||
481 |
methodGeneratorHolder notNil ifTrue:[ |
|
482 |
oldValue := methodGeneratorHolder value. |
|
483 |
methodGeneratorHolder removeDependent:self. |
|
484 |
]. |
|
485 |
methodGeneratorHolder := something. |
|
486 |
methodGeneratorHolder notNil ifTrue:[ |
|
487 |
methodGeneratorHolder addDependent:self. |
|
488 |
]. |
|
489 |
newValue := methodGeneratorHolder value. |
|
490 |
oldValue ~~ newValue ifTrue:[ |
|
491 |
self update:#value with:newValue from:methodGeneratorHolder. |
|
492 |
]. |
|
493 |
! |
|
494 |
||
495 |
progressHolder |
|
496 |
"return/create the 'progressHolder' value holder (automatically generated)" |
|
497 |
||
498 |
progressHolder isNil ifTrue:[ |
|
499 |
progressHolder := ValueHolder new. |
|
500 |
]. |
|
501 |
^ progressHolder |
|
502 |
! |
|
503 |
||
504 |
resultBackgroundColorAspect |
|
505 |
<resource: #uiAspect> |
|
506 |
resultBackgroundColorHolder isNil ifTrue:[ |
|
10165
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
507 |
resultBackgroundColorHolder := BlockValue |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
508 |
with:[:result :running | |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
509 |
running ifTrue:[ |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
510 |
self class currentlyRunningColor "/ View defaultBackgroundColor |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
511 |
] ifFalse:[ |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
512 |
result ifNil:[ self class notRunColor ] ifNotNil:[ result color ] |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
513 |
] |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
514 |
] |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
515 |
argument:self resultHolder |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
516 |
argument:self runningHolder. |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
517 |
resultBackgroundColorHolder |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
518 |
onChangeEvaluate:[ |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
519 |
runnerPanel |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
520 |
ifNotNil:[ runnerPanel backgroundColor:resultBackgroundColorHolder value ] |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
521 |
]. |
9954 | 522 |
]. |
523 |
^ resultBackgroundColorHolder. |
|
524 |
||
525 |
"Created: / 15-03-2010 / 15:22:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
526 |
"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
|
527 |
"Modified (comment): / 05-07-2011 / 14:13:30 / cg" |
9954 | 528 |
! |
529 |
||
530 |
resultHolder |
|
531 |
"return/create the 'resultHolder' value holder (automatically generated)" |
|
532 |
||
533 |
resultHolder isNil ifTrue:[ |
|
534 |
resultHolder := ValueHolder new. |
|
535 |
]. |
|
536 |
^ resultHolder |
|
537 |
! |
|
538 |
||
539 |
resultInfoAspect |
|
540 |
||
541 |
^BlockValue |
|
542 |
with: |
|
543 |
[:model| |
|
544 |
model |
|
545 |
ifNil:[''] |
|
546 |
ifNotNil:[model info]] |
|
547 |
argument: |
|
548 |
self resultHolder |
|
549 |
||
550 |
"Created: / 15-03-2010 / 20:22:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
551 |
! |
|
552 |
||
553 |
resultNameAspect |
|
554 |
||
555 |
^BlockValue |
|
556 |
with: |
|
557 |
[:model| |
|
558 |
model |
|
559 |
ifNil:['Run the tests!!'] |
|
560 |
ifNotNil:[model name]] |
|
561 |
argument: |
|
562 |
self resultHolder |
|
563 |
||
564 |
"Created: / 15-03-2010 / 14:57:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
565 |
"Modified: / 15-03-2010 / 20:17:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
566 |
! |
|
567 |
||
568 |
runAllEnabledHolder |
|
569 |
||
570 |
^true |
|
571 |
||
572 |
"Created: / 07-09-2010 / 09:15:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
573 |
! |
|
574 |
||
575 |
runEnabledHolder |
|
576 |
||
577 |
^BlockValue |
|
578 |
with: |
|
579 |
[:resultHolder | | result | |
|
580 |
(result := resultHolder value) notNil and:[result testCount > 0 ]] |
|
581 |
argument: self resultHolder |
|
582 |
||
583 |
"Created: / 07-09-2010 / 09:15:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
584 |
! |
|
585 |
||
586 |
runningHolder |
|
587 |
"return/create the 'runningHolder' value holder (automatically generated)" |
|
588 |
||
589 |
runningHolder isNil ifTrue:[ |
|
590 |
runningHolder := ValueHolder with: false. |
|
591 |
]. |
|
592 |
^ runningHolder |
|
593 |
||
594 |
"Modified: / 15-03-2010 / 20:29:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
595 |
! |
|
596 |
||
597 |
selectedClassesHolder |
|
598 |
"return/create the 'selectedClassesHolder' value holder (automatically generated)" |
|
599 |
||
600 |
selectedClassesHolder isNil ifTrue:[ |
|
601 |
selectedClassesHolder := ValueHolder new. |
|
602 |
selectedClassesHolder addDependent:self. |
|
603 |
]. |
|
604 |
^ selectedClassesHolder |
|
605 |
! |
|
606 |
||
607 |
selectedClassesHolder:something |
|
608 |
"set the 'selectedClassesHolder' value holder (automatically generated)" |
|
609 |
||
610 |
|oldValue newValue| |
|
611 |
||
612 |
selectedClassesHolder notNil ifTrue:[ |
|
613 |
oldValue := selectedClassesHolder value. |
|
614 |
selectedClassesHolder removeDependent:self. |
|
615 |
]. |
|
616 |
selectedClassesHolder := something. |
|
617 |
selectedClassesHolder notNil ifTrue:[ |
|
618 |
selectedClassesHolder addDependent:self. |
|
619 |
]. |
|
620 |
newValue := selectedClassesHolder value. |
|
621 |
oldValue ~~ newValue ifTrue:[ |
|
622 |
self update:#value with:newValue from:selectedClassesHolder. |
|
623 |
]. |
|
624 |
! |
|
625 |
||
626 |
selectedMethodsHolder |
|
627 |
"return/create the 'selectedMethodsHolder' value holder (automatically generated)" |
|
628 |
||
629 |
selectedMethodsHolder isNil ifTrue:[ |
|
630 |
selectedMethodsHolder := ValueHolder new. |
|
631 |
selectedMethodsHolder addDependent:self. |
|
632 |
]. |
|
633 |
^ selectedMethodsHolder |
|
634 |
! |
|
635 |
||
636 |
selectedMethodsHolder:something |
|
637 |
"set the 'selectedMethodsHolder' value holder (automatically generated)" |
|
638 |
||
639 |
|oldValue newValue| |
|
640 |
||
641 |
selectedMethodsHolder notNil ifTrue:[ |
|
642 |
oldValue := selectedMethodsHolder value. |
|
643 |
selectedMethodsHolder removeDependent:self. |
|
644 |
]. |
|
645 |
selectedMethodsHolder := something. |
|
646 |
selectedMethodsHolder notNil ifTrue:[ |
|
647 |
selectedMethodsHolder addDependent:self. |
|
648 |
]. |
|
649 |
newValue := selectedMethodsHolder value. |
|
650 |
oldValue ~~ newValue ifTrue:[ |
|
651 |
self update:#value with:newValue from:selectedMethodsHolder. |
|
652 |
]. |
|
653 |
! |
|
654 |
||
655 |
selectedProtocolsHolder |
|
656 |
"return/create the 'selectedProtocolsHolder' value holder (automatically generated)" |
|
657 |
||
658 |
selectedProtocolsHolder isNil ifTrue:[ |
|
659 |
selectedProtocolsHolder := ValueHolder new. |
|
660 |
selectedProtocolsHolder addDependent:self. |
|
661 |
]. |
|
662 |
^ selectedProtocolsHolder |
|
663 |
! |
|
664 |
||
665 |
selectedProtocolsHolder:something |
|
666 |
"set the 'selectedProtocolsHolder' value holder (automatically generated)" |
|
667 |
||
668 |
|oldValue newValue| |
|
669 |
||
670 |
selectedProtocolsHolder notNil ifTrue:[ |
|
671 |
oldValue := selectedProtocolsHolder value. |
|
672 |
selectedProtocolsHolder removeDependent:self. |
|
673 |
]. |
|
674 |
selectedProtocolsHolder := something. |
|
675 |
selectedProtocolsHolder notNil ifTrue:[ |
|
676 |
selectedProtocolsHolder addDependent:self. |
|
677 |
]. |
|
678 |
newValue := selectedProtocolsHolder value. |
|
679 |
oldValue ~~ newValue ifTrue:[ |
|
680 |
self update:#value with:newValue from:selectedProtocolsHolder. |
|
681 |
]. |
|
682 |
! ! |
|
683 |
||
684 |
!TestRunnerEmbedded methodsFor:'change & update'! |
|
685 |
||
686 |
update:aspect with:param from: sender |
|
687 |
"Invoked when an object that I depend upon sends a change notification." |
|
688 |
||
689 |
sender == selectedClassesHolder ifTrue:[ |
|
690 |
self |
|
691 |
updateTestCases; |
|
692 |
updateTestSuiteAndResult; |
|
693 |
updateVisibility. |
|
694 |
^ self. |
|
695 |
]. |
|
696 |
sender == selectedProtocolsHolder ifTrue:[ |
|
697 |
self updateTestSuiteAndResult. |
|
698 |
^self |
|
699 |
]. |
|
700 |
||
701 |
sender == selectedMethodsHolder ifTrue:[ |
|
702 |
self updateTestSuiteAndResult. |
|
703 |
^self |
|
704 |
]. |
|
705 |
sender == methodGeneratorHolder ifTrue:[ |
|
706 |
self updateTestSuiteAndResult. |
|
707 |
^self |
|
708 |
]. |
|
709 |
||
710 |
||
711 |
||
712 |
super update:aspect with:param from: sender |
|
713 |
||
714 |
"Modified: / 07-09-2010 / 08:18:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
715 |
! |
|
716 |
||
717 |
updateTestCases |
|
718 |
selectedTestCases := (self selectedClassesHolder value |
|
719 |
select:[:cls | self isTestCaseLike:cls ]). |
|
720 |
selectedTestCases := selectedTestCases isEmpty |
|
721 |
ifTrue:[ nil ] |
|
722 |
ifFalse:[ selectedTestCases asArray ] |
|
723 |
||
724 |
"Created: / 11-03-2010 / 10:31:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
725 |
"Modified: / 15-03-2010 / 20:53:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
726 |
! |
|
727 |
||
728 |
updateTestSuiteAndResult |
|
729 |
||
730 |
| suite suiteAndResult | |
|
731 |
self runningHolder value ifTrue:[^self]. |
|
732 |
selectedTestCases ifNil:[^self]. |
|
733 |
suiteAndResult := SuiteAndResult |
|
734 |
suite: (suite := self suiteForRun) |
|
735 |
result: (self resultForSuite: suite). |
|
736 |
self resultHolder value: suiteAndResult. |
|
737 |
||
738 |
"Created: / 15-03-2010 / 19:41:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
739 |
"Modified: / 15-03-2010 / 20:55:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
740 |
! |
|
741 |
||
742 |
updateVisibility |
|
743 |
||
744 |
self hasTestCaseSelected |
|
745 |
ifTrue:[self show] |
|
746 |
ifFalse:[self hide] |
|
747 |
||
748 |
"Created: / 11-03-2010 / 09:02:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
749 |
! ! |
|
750 |
||
751 |
!TestRunnerEmbedded methodsFor:'hooks'! |
|
752 |
||
753 |
postBuildRunnerPanel: aView |
|
754 |
||
755 |
runnerPanel := aView. |
|
756 |
runnerPanel backgroundColor: self resultBackgroundColorAspect value |
|
757 |
||
758 |
"Created: / 15-03-2010 / 14:26:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
759 |
! ! |
|
760 |
||
761 |
!TestRunnerEmbedded methodsFor:'private'! |
|
762 |
||
763 |
hide |
|
764 |
||
765 |
self visibility: false height: 0 |
|
766 |
||
767 |
"Created: / 11-03-2010 / 09:07:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
768 |
! |
|
769 |
||
770 |
isTestCaseLike:cls |
|
771 |
||
772 |
^(super isTestCaseLike: cls) and: |
|
773 |
[(cls askFor: #isAbstract) not] |
|
774 |
||
775 |
"Modified: / 04-03-2011 / 06:54:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
776 |
! |
|
777 |
||
778 |
show |
|
779 |
||
780 |
self visibility: true height: 50 |
|
781 |
||
782 |
"Created: / 11-03-2010 / 09:07:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
783 |
! |
|
784 |
||
785 |
visibility: visibility height: height |
|
786 |
| container list h | |
|
787 |
(container := self window container) ifNil:[^self]. |
|
788 |
h := visibility ifFalse:[0] ifTrue:[height]. |
|
789 |
||
790 |
container isVisible == visibility ifFalse: |
|
791 |
[container isVisible: visibility]. |
|
792 |
||
793 |
||
794 |
list := container container subViews first. |
|
795 |
||
796 |
(list layout bottomOffset ~= height negated) ifTrue: |
|
797 |
[list layout: |
|
798 |
(list layout bottomOffset: height negated; yourself)]. |
|
799 |
||
800 |
"Created: / 11-03-2010 / 09:51:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
801 |
! ! |
|
802 |
||
803 |
!TestRunnerEmbedded methodsFor:'queries'! |
|
804 |
||
805 |
hasTestCaseSelected |
|
806 |
||
807 |
^selectedTestCases isNilOrEmptyCollection not |
|
808 |
||
809 |
"Created: / 11-03-2010 / 09:06:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
810 |
"Modified: / 15-03-2010 / 20:54:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
811 |
! ! |
|
812 |
||
813 |
!TestRunnerEmbedded methodsFor:'utilities'! |
|
814 |
||
815 |
resultForSuite: suite |
|
816 |
||
817 |
| result | |
|
818 |
result := TestResult new. |
|
819 |
suite tests do: |
|
820 |
[:test| |
|
821 |
(test class testSelectorPassed: test selector) |
|
822 |
ifTrue: |
|
823 |
[result passed add: test] |
|
824 |
ifFalse: |
|
825 |
[(test class testSelectorError: test selector) |
|
826 |
ifTrue: |
|
827 |
[result errors add: test] |
|
828 |
ifFalse: |
|
829 |
[(test class testSelectorFailed: test selector) |
|
830 |
ifTrue: |
|
831 |
[result failures add: test]]]]. |
|
832 |
^result |
|
833 |
||
834 |
"Created: / 15-03-2010 / 19:46:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
835 |
! |
|
836 |
||
837 |
suiteForRun |
|
838 |
| methods protocols suite | |
|
839 |
(methods := selectedMethodsHolder value) isNilOrEmptyCollection ifFalse: |
|
840 |
[suite := TestSuite named: (self suiteNameFromMethods: methods). |
|
841 |
self selectedTestMethods do: |
|
842 |
[:mthd| | selector | |
|
843 |
suite addTest: (mthd mclass asTestCase selector: mthd selector)]. |
|
844 |
^suite]. |
|
845 |
||
846 |
(protocols := selectedProtocolsHolder value) isNilOrEmptyCollection ifFalse: |
|
847 |
[suite := TestSuite named: (self suiteNameFromProtocols: protocols). |
|
848 |
(self selectedTestMethodsFromProtocols: protocols) do: |
|
849 |
[:mthd| | selector | |
|
850 |
suite addTest: (mthd mclass asTestCase selector: mthd selector)]. |
|
851 |
^suite]. |
|
852 |
^self suiteForRunAll |
|
853 |
||
854 |
"Created: / 15-03-2010 / 13:13:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
855 |
"Modified: / 04-03-2011 / 08:24:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
856 |
! |
|
857 |
||
858 |
suiteForRunAll |
|
859 |
|suite| |
|
860 |
suite := TestSuite named:(self suiteNameFromClasses: selectedTestCases). |
|
861 |
selectedTestCases |
|
862 |
do:[:testCase | suite addTests:(self buildSuiteFromClass:testCase) tests]. |
|
863 |
^suite |
|
864 |
||
865 |
"Modified: / 04-03-2011 / 06:57:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
866 |
! ! |
|
867 |
||
868 |
!TestRunnerEmbedded::SuiteAndResult class methodsFor:'instance creation'! |
|
869 |
||
870 |
suite: suite result: result |
|
871 |
||
872 |
^self new |
|
873 |
suite: suite; |
|
874 |
result: result. |
|
875 |
||
876 |
"Modified: / 15-03-2010 / 15:27:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
877 |
! ! |
|
878 |
||
879 |
!TestRunnerEmbedded::SuiteAndResult methodsFor:'accessing'! |
|
880 |
||
881 |
color |
|
882 |
||
883 |
self testCount == 0 ifTrue: |
|
884 |
[^TestRunnerEmbedded notRunColor]. |
|
885 |
||
886 |
result ifNil:[^TestRunnerEmbedded notRunColor]. |
|
887 |
self hasErrors ifTrue:[^TestRunnerEmbedded errorColor]. |
|
888 |
self hasFailures ifTrue:[^TestRunnerEmbedded failedColor]. |
|
889 |
self hasPassed ifTrue:[^TestRunnerEmbedded passedColor]. |
|
890 |
^TestRunnerEmbedded notRunColor |
|
891 |
||
892 |
"Created: / 15-03-2010 / 15:24:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
893 |
"Modified: / 07-09-2010 / 08:25:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
894 |
! |
|
895 |
||
896 |
info |
|
897 |
||
898 |
result ifNil:[^'']. |
|
899 |
(result passedCount + result failureCount + result errorCount) = 1 ifTrue:[^'']. |
|
900 |
^'%1 tests, %2 passed, %3 failed, %4 errors' |
|
901 |
bindWith: suite tests size |
|
902 |
with: result passedCount |
|
903 |
with: result failureCount |
|
904 |
with: result errorCount |
|
905 |
||
906 |
"Created: / 15-03-2010 / 20:23:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
907 |
! |
|
908 |
||
909 |
name |
|
910 |
||
911 |
^suite name |
|
912 |
||
913 |
"Created: / 15-03-2010 / 15:12:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
914 |
! |
|
915 |
||
916 |
result |
|
917 |
^ result |
|
918 |
! |
|
919 |
||
920 |
result:aTestResult |
|
921 |
result := aTestResult. |
|
922 |
! |
|
923 |
||
924 |
suite |
|
925 |
^ suite |
|
926 |
! |
|
927 |
||
928 |
suite:aTestSuite |
|
929 |
suite := aTestSuite. |
|
930 |
! |
|
931 |
||
932 |
testCount |
|
933 |
||
934 |
^suite tests size |
|
935 |
||
936 |
"Created: / 15-03-2010 / 15:44:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
937 |
! ! |
|
938 |
||
939 |
!TestRunnerEmbedded::SuiteAndResult methodsFor:'queries'! |
|
940 |
||
941 |
hasErrors |
|
942 |
||
943 |
^result errorCount > 0 |
|
944 |
||
945 |
"Created: / 15-03-2010 / 15:21:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
946 |
! |
|
947 |
||
948 |
hasFailures |
|
949 |
||
950 |
^result failureCount > 0 |
|
951 |
||
952 |
"Created: / 15-03-2010 / 15:21:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
953 |
! |
|
954 |
||
955 |
hasFailuresOrErrors |
|
956 |
||
957 |
^self hasErrors or:[self hasFailures] |
|
958 |
||
959 |
"Created: / 15-03-2010 / 15:45:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
960 |
! |
|
961 |
||
962 |
hasPassed |
|
963 |
||
964 |
^result passedCount > 0 |
|
965 |
||
966 |
"Created: / 15-03-2010 / 22:06:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
967 |
! ! |
|
968 |
||
969 |
!TestRunnerEmbedded class methodsFor:'documentation'! |
|
970 |
||
971 |
version_CVS |
|
10243
f8b2067424ed
changed: #debug: bug fix: if the test pass when debugging, update the UI
vrany
parents:
10201
diff
changeset
|
972 |
^ '$Header: /cvs/stx/stx/libtool/Tools__TestRunnerEmbedded.st,v 1.9 2011-07-07 10:40:45 vrany Exp $' |
9954 | 973 |
! |
974 |
||
975 |
version_SVN |
|
976 |
^ '§Id: Tools__TestRunnerEmbedded.st 7681 2011-03-04 11:30:02Z vranyj1 §' |
|
977 |
! ! |