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