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