author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Tue, 05 Jun 2012 15:49:00 +0100 | |
branch | jv |
changeset 12254 | b1237f76f501 |
parent 12128 | a7ff7d66ee85 |
child 12262 | d25ef6bb0ef3 |
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 |
|
12254 | 31 |
instanceVariableNames:'runnerPanel selectedClassesHolder selectedProtocolsHolder |
32 |
selectedMethodsHolder methodGeneratorHolder resultHolder |
|
33 |
resultInfoHolder resultBackgroundColorHolder runningHolder |
|
34 |
progressHolder progressIndicatorShownHolder infoHolder |
|
35 |
testProcess allTestCases' |
|
10647
1e9912f9a0d8
Embedded test runner no longer reuse old testcase instances
vrany
parents:
10608
diff
changeset
|
36 |
classVariableNames:'' |
1e9912f9a0d8
Embedded test runner no longer reuse old testcase instances
vrany
parents:
10608
diff
changeset
|
37 |
poolDictionaries:'' |
1e9912f9a0d8
Embedded test runner no longer reuse old testcase instances
vrany
parents:
10608
diff
changeset
|
38 |
category:'SUnit-UI' |
9954 | 39 |
! |
40 |
||
41 |
Object subclass:#SuiteAndResult |
|
10647
1e9912f9a0d8
Embedded test runner no longer reuse old testcase instances
vrany
parents:
10608
diff
changeset
|
42 |
instanceVariableNames:'suite result' |
1e9912f9a0d8
Embedded test runner no longer reuse old testcase instances
vrany
parents:
10608
diff
changeset
|
43 |
classVariableNames:'' |
1e9912f9a0d8
Embedded test runner no longer reuse old testcase instances
vrany
parents:
10608
diff
changeset
|
44 |
poolDictionaries:'' |
1e9912f9a0d8
Embedded test runner no longer reuse old testcase instances
vrany
parents:
10608
diff
changeset
|
45 |
privateIn:TestRunnerEmbedded |
9954 | 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 |
||
12254 | 84 |
!TestRunnerEmbedded class methodsFor:'help specs'! |
85 |
||
86 |
flyByHelpSpec |
|
87 |
"This resource specification was automatically generated |
|
88 |
by the UIHelpTool of ST/X." |
|
89 |
||
90 |
"Do not manually edit this!! If it is corrupted, |
|
91 |
the UIHelpTool may not be able to read the specification." |
|
92 |
||
93 |
" |
|
94 |
UIHelpTool openOnClass:Tools::TestRunnerEmbedded |
|
95 |
" |
|
96 |
||
97 |
<resource: #help> |
|
98 |
||
99 |
^ super flyByHelpSpec addPairsFrom:#( |
|
100 |
||
101 |
#debugSelected |
|
102 |
'Run the selected test(s) with debugging enabled' |
|
103 |
||
104 |
#runAll |
|
105 |
'Run all tests' |
|
106 |
||
107 |
#runFailed |
|
108 |
'Only rerun failed tests' |
|
109 |
||
110 |
#runSelected |
|
111 |
'Run the selected test(s)' |
|
112 |
||
113 |
#stopRun |
|
114 |
'Stop the test-run' |
|
115 |
||
116 |
) |
|
117 |
||
118 |
"Created: / 04-06-2012 / 19:27:47 / cg" |
|
119 |
! ! |
|
120 |
||
9954 | 121 |
!TestRunnerEmbedded class methodsFor:'interface specs'! |
122 |
||
123 |
windowSpec |
|
124 |
"This resource specification was automatically generated |
|
125 |
by the UIPainter of ST/X." |
|
126 |
||
127 |
"Do not manually edit this!! If it is corrupted, |
|
128 |
the UIPainter may not be able to read the specification." |
|
129 |
||
130 |
" |
|
131 |
UIPainter new openOnClass:Tools::TestRunnerEmbedded andSelector:#windowSpec |
|
132 |
Tools::TestRunnerEmbedded new openInterface:#windowSpec |
|
133 |
Tools::TestRunnerEmbedded open |
|
134 |
" |
|
135 |
||
136 |
<resource: #canvas> |
|
137 |
||
138 |
^ |
|
139 |
#(FullSpec |
|
140 |
name: windowSpec |
|
141 |
window: |
|
142 |
(WindowSpec |
|
143 |
label: 'Test Runner Embedded' |
|
144 |
name: 'Test Runner Embedded' |
|
145 |
min: (Point 10 10) |
|
12254 | 146 |
bounds: (Rectangle 0 0 595 50) |
9954 | 147 |
) |
148 |
component: |
|
149 |
(SpecCollection |
|
150 |
collection: ( |
|
12254 | 151 |
(ViewSpec |
152 |
name: 'Runner' |
|
9954 | 153 |
layout: (LayoutFrame 5 0 0 0 -5 1 0 1) |
12254 | 154 |
backgroundChannel: resultBackgroundColorAspect |
9954 | 155 |
component: |
156 |
(SpecCollection |
|
157 |
collection: ( |
|
12254 | 158 |
(HorizontalPanelViewSpec |
159 |
name: 'RunnerInnerBox' |
|
160 |
layout: (LayoutFrame 5 0 0 0 -5 1 0 1) |
|
9954 | 161 |
backgroundChannel: resultBackgroundColorAspect |
12254 | 162 |
horizontalLayout: rightSpaceFit |
163 |
verticalLayout: center |
|
164 |
horizontalSpace: 0 |
|
165 |
elementsChangeSize: true |
|
9954 | 166 |
component: |
167 |
(SpecCollection |
|
168 |
collection: ( |
|
12254 | 169 |
(ViewSpec |
170 |
name: 'RunnerInfoBox' |
|
171 |
backgroundChannel: resultBackgroundColorAspect |
|
9954 | 172 |
component: |
173 |
(SpecCollection |
|
174 |
collection: ( |
|
12254 | 175 |
(LabelSpec |
176 |
label: 'Run tests first!!' |
|
177 |
name: 'ResultName' |
|
178 |
layout: (LayoutFrame 0 0 0 0 0 1 -10 1) |
|
179 |
backgroundChannel: resultBackgroundColorAspect |
|
180 |
foregroundColor: (Color 100.0 100.0 100.0) |
|
181 |
translateLabel: true |
|
182 |
labelChannel: resultNameAspect |
|
183 |
adjust: left |
|
184 |
) |
|
185 |
(LabelSpec |
|
186 |
name: 'ResultInfo' |
|
187 |
layout: (LayoutFrame 0 0 -10 1 0 1 0 1) |
|
188 |
style: (FontDescription helvetica medium roman 8 #'iso10646-1') |
|
189 |
backgroundChannel: resultBackgroundColorAspect |
|
190 |
foregroundColor: (Color 100.0 100.0 100.0) |
|
191 |
translateLabel: true |
|
192 |
labelChannel: resultInfoAspect |
|
193 |
adjust: left |
|
194 |
) |
|
9954 | 195 |
(ViewSpec |
12254 | 196 |
name: 'ProgressPanel' |
197 |
layout: (LayoutFrame 0 0 0 0 0 1 0 1) |
|
198 |
visibilityChannel: progressIndicatorShownHolder |
|
9954 | 199 |
backgroundChannel: resultBackgroundColorAspect |
200 |
component: |
|
201 |
(SpecCollection |
|
202 |
collection: ( |
|
12254 | 203 |
(ProgressIndicatorSpec |
204 |
name: 'RunningProgress' |
|
205 |
layout: (LayoutFrame 5 0 -10 0.5 -5 1 10 0.5) |
|
206 |
model: progressHolder |
|
9954 | 207 |
) |
208 |
) |
|
209 |
||
210 |
) |
|
211 |
) |
|
212 |
) |
|
213 |
||
214 |
) |
|
12254 | 215 |
extent: (Point 276 30) |
216 |
) |
|
217 |
(ActionButtonSpec |
|
218 |
label: 'Stop' |
|
219 |
name: 'Button2' |
|
220 |
activeHelpKey: stopRun |
|
221 |
visibilityChannel: runningHolder |
|
222 |
translateLabel: true |
|
223 |
model: stop |
|
224 |
extent: (Point 60 25) |
|
225 |
) |
|
226 |
(ActionButtonSpec |
|
227 |
label: 'Run' |
|
228 |
name: 'Run' |
|
229 |
activeHelpKey: runSelected |
|
230 |
visibilityChannel: notRunningHolder |
|
231 |
translateLabel: true |
|
232 |
model: run |
|
233 |
enableChannel: runEnabledHolder |
|
234 |
extent: (Point 60 25) |
|
235 |
) |
|
236 |
(ActionButtonSpec |
|
237 |
label: 'Debug' |
|
238 |
name: 'DebugButton' |
|
239 |
activeHelpKey: debugSelected |
|
240 |
translateLabel: true |
|
241 |
model: debug |
|
242 |
enableChannel: runEnabledHolder |
|
243 |
extent: (Point 60 25) |
|
244 |
) |
|
245 |
(ActionButtonSpec |
|
246 |
label: 'Run Failed' |
|
247 |
name: 'Button1' |
|
248 |
activeHelpKey: runFailed |
|
249 |
translateLabel: true |
|
250 |
model: runFailed |
|
251 |
enableChannel: runFailedEnabledHolder |
|
252 |
extent: (Point 60 25) |
|
253 |
) |
|
254 |
(ActionButtonSpec |
|
255 |
label: 'Run all' |
|
256 |
name: 'RunAll' |
|
257 |
activeHelpKey: runAll |
|
258 |
translateLabel: true |
|
259 |
model: runAll |
|
260 |
enableChannel: runAllEnabledHolder |
|
261 |
extent: (Point 60 25) |
|
9954 | 262 |
) |
263 |
) |
|
264 |
||
265 |
) |
|
12254 | 266 |
postBuildCallback: postBuildRunnerPanel: |
9954 | 267 |
) |
268 |
) |
|
269 |
||
270 |
) |
|
271 |
) |
|
272 |
) |
|
273 |
||
274 |
) |
|
275 |
) |
|
276 |
||
277 |
! ! |
|
278 |
||
279 |
!TestRunnerEmbedded class methodsFor:'plugIn spec'! |
|
280 |
||
281 |
aspectSelectors |
|
282 |
"This resource specification was automatically generated |
|
283 |
by the UIPainter of ST/X." |
|
284 |
||
285 |
"Do not manually edit this. If it is corrupted, |
|
286 |
the UIPainter may not be able to read the specification." |
|
287 |
||
288 |
"Return a description of exported aspects; |
|
289 |
these can be connected to aspects of an embedding application |
|
290 |
(if this app is embedded in a subCanvas)." |
|
291 |
||
292 |
^ #( |
|
293 |
#methodGeneratorHolder |
|
294 |
#selectedClassesHolder |
|
295 |
#selectedMethodsHolder |
|
296 |
#selectedProtocolsHolder |
|
297 |
). |
|
298 |
||
299 |
! ! |
|
300 |
||
301 |
!TestRunnerEmbedded methodsFor:'accessing'! |
|
302 |
||
10175 | 303 |
infoHolder:something |
304 |
"to show something in the browsers info area (near the bottom" |
|
305 |
||
306 |
infoHolder := something. |
|
307 |
||
308 |
"Created: / 05-07-2011 / 16:22:24 / cg" |
|
309 |
! |
|
310 |
||
9954 | 311 |
selectedTestMethods |
10374 | 312 |
|
313 |
| selectedClass | |
|
314 |
selectedClass := self theSingleTestCase. |
|
315 |
||
9954 | 316 |
^ (self selectedMethodsHolder value ? #()) select: |
10374 | 317 |
[:mthd | | cls | |
10431
a18faf41394b
changed: #selectedTestMethods
Claus Gittinger <cg@exept.de>
parents:
10374
diff
changeset
|
318 |
(cls := selectedClass) isNil ifTrue:[cls := mthd mclass]. |
10374 | 319 |
(self isTestCaseLike:selectedClass) |
320 |
and:[ selectedClass isTestSelector:mthd selector ] ] |
|
9954 | 321 |
|
322 |
"Created: / 15-03-2010 / 13:21:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10374 | 323 |
"Modified: / 22-07-2011 / 15:46:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10431
a18faf41394b
changed: #selectedTestMethods
Claus Gittinger <cg@exept.de>
parents:
10374
diff
changeset
|
324 |
"Modified: / 02-08-2011 / 17:46:38 / cg" |
9954 | 325 |
! |
326 |
||
327 |
selectedTestMethodsFromProtocols:protocols |
|
10374 | 328 |
|
329 |
|methods generator selectedClass| |
|
9954 | 330 |
|
331 |
methods := Set new. |
|
332 |
generator := self methodGeneratorHolder value. |
|
10374 | 333 |
selectedClass := self theSingleTestCase. |
334 |
||
12254 | 335 |
generator notNil ifTrue:[ |
336 |
generator do: [:cls :cat :sel :mthd | |
|
337 |
(mthd notNil |
|
338 |
and:[ (self isTestCaseLike:(selectedClass ? cls)) |
|
339 |
and:[ (selectedClass ? cls) isTestSelector:sel ] ]) |
|
340 |
ifTrue:[ methods add:mthd ] |
|
341 |
] |
|
342 |
] ifFalse:[ |
|
343 |
allTestCases do: [:cls | |
|
344 |
cls methodsDo: [:mthd | |
|
345 |
((protocols includes:mthd category) and:[ cls isTestSelector:mthd selector ]) |
|
346 |
ifTrue:[ |
|
347 |
methods add:mthd |
|
348 |
] |
|
349 |
] |
|
350 |
] |
|
351 |
]. |
|
9954 | 352 |
^ methods |
353 |
||
354 |
"Created: / 15-03-2010 / 19:50:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10374 | 355 |
"Modified: / 22-07-2011 / 15:53:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
12254 | 356 |
"Modified (format): / 04-06-2012 / 19:05:32 / cg" |
10374 | 357 |
! |
358 |
||
359 |
theSingleTestCase |
|
360 |
||
12254 | 361 |
allTestCases isEmptyOrNil ifTrue:[^nil]. |
362 |
allTestCases size > 1 ifTrue:[^nil]. |
|
10374 | 363 |
|
12254 | 364 |
^allTestCases anyOne. |
10374 | 365 |
|
366 |
"Created: / 22-07-2011 / 15:44:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
9954 | 367 |
! ! |
368 |
||
369 |
!TestRunnerEmbedded methodsFor:'actions'! |
|
370 |
||
371 |
debug |
|
10432 | 372 |
| suiteAndResult suite test result | |
9954 | 373 |
|
374 |
suiteAndResult := self resultHolder value. |
|
12125 | 375 |
suite := suiteAndResult suiteForRun. |
12254 | 376 |
"/ suite tests size ~= 1 ifTrue:[^self breakPoint: #jv]. |
377 |
"/ test := suiteAndResult suite tests anyOne. |
|
378 |
||
379 |
self stop. |
|
380 |
||
381 |
testProcess := |
|
382 |
[ |
|
383 |
[ |
|
384 |
self runningHolder value:true. |
|
385 |
||
386 |
suite tests do:[:test | |
|
387 |
test debug. |
|
388 |
(test class testSelectorPassed:test selector) ifTrue:[ |
|
389 |
result := TestResult new. |
|
390 |
result passed add: test. |
|
391 |
suiteAndResult := SuiteAndResult suite: suite result: result. |
|
392 |
self resultHolder value:suiteAndResult. |
|
393 |
]. |
|
394 |
]. |
|
395 |
] ensure:[ |
|
396 |
self runningHolder value:false. |
|
397 |
]. |
|
398 |
] newProcess. |
|
399 |
testProcess priority:(Processor userBackgroundPriority). |
|
400 |
testProcess resume. |
|
9954 | 401 |
|
402 |
"Created: / 15-03-2010 / 15:43:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10243
f8b2067424ed
changed: #debug: bug fix: if the test pass when debugging, update the UI
vrany
parents:
10201
diff
changeset
|
403 |
"Modified: / 07-07-2011 / 11:33:48 / Jan Vrany <jan.vrant@fit.cvut,cz>" |
12125 | 404 |
"Modified: / 22-08-2011 / 09:59:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
12254 | 405 |
"Modified: / 04-06-2012 / 19:46:38 / cg" |
9954 | 406 |
! |
407 |
||
408 |
run |
|
12125 | 409 |
|suite| |
9954 | 410 |
|
12125 | 411 |
resultHolder value isNil ifTrue:[ |
412 |
suite := self suiteForRun |
|
413 |
] ifFalse:[ |
|
414 |
suite := resultHolder value suiteForRun |
|
415 |
]. |
|
416 |
self run:suite |
|
9954 | 417 |
|
418 |
"Created: / 10-03-2010 / 19:42:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
12125 | 419 |
"Modified: / 22-08-2011 / 09:58:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
420 |
"Modified: / 09-10-2011 / 10:56:39 / cg" |
|
9954 | 421 |
! |
422 |
||
10175 | 423 |
run:suite |
12254 | 424 |
|suiteAndResult numTests| |
9954 | 425 |
|
10201 | 426 |
numTests := suite tests size. |
427 |
numTests == 0 ifTrue:[ |
|
10175 | 428 |
^ self |
429 |
]. |
|
9954 | 430 |
|
12254 | 431 |
self stop. |
432 |
||
433 |
testProcess := [ |
|
10175 | 434 |
|result incr run| |
9954 | 435 |
|
10175 | 436 |
[ |
12254 | 437 |
self runningHolder value:true. |
438 |
self progressIndicatorShownHolder value:(numTests size > 1). |
|
10175 | 439 |
self progressHolder value:0. |
10201 | 440 |
incr := 100 / numTests. |
10175 | 441 |
run := 0. |
442 |
result := suite |
|
443 |
runBeforeEachDo:[:test :result | |
|
444 |
infoHolder notNil ifTrue:[ |
|
445 |
infoHolder value:('Running "%1-%2"...' |
|
446 |
bindWith:test name |
|
447 |
with:test getTestName allBold) |
|
448 |
] |
|
449 |
] |
|
450 |
afterEachDo:[:test :result | |
|
451 |
run := run + 1. |
|
10184 | 452 |
self progressHolder value:(incr * run) truncated "rounded". |
10175 | 453 |
infoHolder notNil ifTrue:[ |
454 |
infoHolder value:('Done.') |
|
455 |
] |
|
456 |
]. |
|
457 |
suiteAndResult := SuiteAndResult suite:suite result:result. |
|
458 |
] ensure:[ |
|
12254 | 459 |
self progressIndicatorShownHolder value:false. |
10175 | 460 |
self resultHolder value:suiteAndResult. |
461 |
self runningHolder value:false. |
|
462 |
] |
|
463 |
] newProcess. |
|
12254 | 464 |
|
465 |
testProcess priority:(Processor userBackgroundPriority). |
|
466 |
testProcess resume. |
|
9954 | 467 |
|
468 |
"Created: / 11-03-2010 / 10:22:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
469 |
"Modified: / 06-09-2010 / 21:48:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
12254 | 470 |
"Modified: / 04-06-2012 / 19:43:34 / cg" |
9954 | 471 |
! |
472 |
||
473 |
runAll |
|
474 |
||
12254 | 475 |
self run: (self suiteForRunAll). |
9954 | 476 |
|
477 |
"Created: / 10-03-2010 / 19:42:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
478 |
"Modified: / 15-03-2010 / 13:12:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
12254 | 479 |
"Modified: / 04-06-2012 / 19:00:14 / cg" |
480 |
! |
|
481 |
||
482 |
runFailed |
|
483 |
self run: self suiteForRunFailed. |
|
484 |
||
485 |
"Created: / 04-06-2012 / 18:32:19 / cg" |
|
10178 | 486 |
! |
487 |
||
488 |
runWithDebug |
|
489 |
"/ cg: I really do not want to run them twice to get a debugger |
|
490 |
"/ - I want to run them either with a debugger coming right away, or not. |
|
491 |
||
12125 | 492 |
| suiteAndResult suite| |
10178 | 493 |
|
494 |
suiteAndResult := self resultHolder value. |
|
12125 | 495 |
suiteAndResult isNil ifTrue:[ |
496 |
suite := self suiteForRun. |
|
497 |
] ifFalse:[ |
|
498 |
suite := suiteAndResult suiteForRun. |
|
499 |
]. |
|
10608 | 500 |
|
12125 | 501 |
suite run: TestResultForRunWithDebug new |
10178 | 502 |
|
503 |
||
504 |
||
505 |
"/ suiteAndResult suite tests size ~= 1 ifTrue:[^self breakPoint: #jv]. |
|
506 |
"/ [suiteAndResult suite tests anyOne debug] fork |
|
507 |
||
508 |
"Created: / 05-07-2011 / 18:45:43 / cg" |
|
12125 | 509 |
"Modified: / 22-08-2011 / 09:59:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
510 |
"Modified: / 09-10-2011 / 10:55:46 / cg" |
|
12254 | 511 |
! |
512 |
||
513 |
stop |
|
514 |
|p| |
|
515 |
||
516 |
(p := testProcess) notNil ifTrue:[ |
|
517 |
testProcess := nil. |
|
518 |
p terminate |
|
519 |
]. |
|
520 |
||
521 |
"Created: / 04-06-2012 / 18:34:07 / cg" |
|
9954 | 522 |
! ! |
523 |
||
524 |
!TestRunnerEmbedded methodsFor:'aspects'! |
|
525 |
||
526 |
debugVisibleAspect |
|
10432 | 527 |
^ BlockValue |
528 |
with:[:model | |
|
529 |
model notNil |
|
530 |
and:[ model testCount == 1 |
|
531 |
and:[ model hasFailuresOrErrors ]] |
|
532 |
] |
|
533 |
argument:self resultHolder |
|
9954 | 534 |
|
535 |
"Created: / 15-03-2010 / 15:40:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10432 | 536 |
"Modified: / 02-08-2011 / 18:19:14 / cg" |
9954 | 537 |
! |
538 |
||
539 |
methodGeneratorHolder |
|
540 |
"return/create the 'methodGeneratorHolder' value holder (automatically generated)" |
|
541 |
||
542 |
methodGeneratorHolder isNil ifTrue:[ |
|
543 |
methodGeneratorHolder := ValueHolder new. |
|
544 |
methodGeneratorHolder addDependent:self. |
|
545 |
]. |
|
546 |
^ methodGeneratorHolder |
|
547 |
! |
|
548 |
||
549 |
methodGeneratorHolder:something |
|
550 |
"set the 'methodGeneratorHolder' value holder (automatically generated)" |
|
551 |
||
552 |
|oldValue newValue| |
|
553 |
||
554 |
methodGeneratorHolder notNil ifTrue:[ |
|
555 |
oldValue := methodGeneratorHolder value. |
|
556 |
methodGeneratorHolder removeDependent:self. |
|
557 |
]. |
|
558 |
methodGeneratorHolder := something. |
|
559 |
methodGeneratorHolder notNil ifTrue:[ |
|
560 |
methodGeneratorHolder addDependent:self. |
|
561 |
]. |
|
562 |
newValue := methodGeneratorHolder value. |
|
563 |
oldValue ~~ newValue ifTrue:[ |
|
564 |
self update:#value with:newValue from:methodGeneratorHolder. |
|
565 |
]. |
|
566 |
! |
|
567 |
||
12254 | 568 |
notRunningHolder |
569 |
^ BlockValue forLogicalNot:(self runningHolder) |
|
570 |
||
571 |
"Created: / 04-06-2012 / 18:38:48 / cg" |
|
572 |
! |
|
573 |
||
9954 | 574 |
progressHolder |
575 |
"return/create the 'progressHolder' value holder (automatically generated)" |
|
576 |
||
577 |
progressHolder isNil ifTrue:[ |
|
578 |
progressHolder := ValueHolder new. |
|
579 |
]. |
|
580 |
^ progressHolder |
|
581 |
! |
|
582 |
||
12254 | 583 |
progressIndicatorShownHolder |
584 |
progressIndicatorShownHolder isNil ifTrue:[ |
|
585 |
progressIndicatorShownHolder := ValueHolder with: false. |
|
586 |
]. |
|
587 |
^ progressIndicatorShownHolder |
|
588 |
||
589 |
"Modified: / 15-03-2010 / 20:29:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
590 |
"Modified (comment): / 04-06-2012 / 18:38:52 / cg" |
|
591 |
"Created: / 04-06-2012 / 19:42:59 / cg" |
|
592 |
! |
|
593 |
||
9954 | 594 |
resultBackgroundColorAspect |
595 |
<resource: #uiAspect> |
|
596 |
resultBackgroundColorHolder isNil ifTrue:[ |
|
10165
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
597 |
resultBackgroundColorHolder := BlockValue |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
598 |
with:[:result :running | |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
599 |
running ifTrue:[ |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
600 |
self class currentlyRunningColor "/ View defaultBackgroundColor |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
601 |
] ifFalse:[ |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
602 |
result ifNil:[ self class notRunColor ] ifNotNil:[ result color ] |
12254 | 603 |
]. |
10165
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
604 |
] |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
605 |
argument:self resultHolder |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
606 |
argument:self runningHolder. |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
607 |
resultBackgroundColorHolder |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
608 |
onChangeEvaluate:[ |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
609 |
runnerPanel |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
610 |
ifNotNil:[ runnerPanel backgroundColor:resultBackgroundColorHolder value ] |
fd4de5081321
changed: #resultBackgroundColorAspect
Claus Gittinger <cg@exept.de>
parents:
10092
diff
changeset
|
611 |
]. |
9954 | 612 |
]. |
613 |
^ resultBackgroundColorHolder. |
|
614 |
||
615 |
"Created: / 15-03-2010 / 15:22:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
616 |
"Modified: / 15-03-2010 / 21:02:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
12254 | 617 |
"Modified: / 04-06-2012 / 19:40:11 / cg" |
9954 | 618 |
! |
619 |
||
620 |
resultHolder |
|
621 |
"return/create the 'resultHolder' value holder (automatically generated)" |
|
622 |
||
623 |
resultHolder isNil ifTrue:[ |
|
624 |
resultHolder := ValueHolder new. |
|
625 |
]. |
|
626 |
^ resultHolder |
|
627 |
! |
|
628 |
||
629 |
resultInfoAspect |
|
10432 | 630 |
^ BlockValue |
631 |
with:[:model | model isNil ifTrue:[ '' ] ifFalse:[ model info ] ] |
|
632 |
argument:self resultHolder |
|
9954 | 633 |
|
634 |
"Created: / 15-03-2010 / 20:22:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10432 | 635 |
"Modified: / 02-08-2011 / 18:20:26 / cg" |
9954 | 636 |
! |
637 |
||
638 |
resultNameAspect |
|
10432 | 639 |
^ BlockValue |
640 |
with:[:model | model isNil ifTrue:[ 'Run the tests!!' ] ifFalse:[ model name ] ] |
|
641 |
argument:self resultHolder |
|
9954 | 642 |
|
643 |
"Created: / 15-03-2010 / 14:57:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
644 |
"Modified: / 15-03-2010 / 20:17:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10432 | 645 |
"Modified: / 02-08-2011 / 18:20:38 / cg" |
9954 | 646 |
! |
647 |
||
648 |
runAllEnabledHolder |
|
649 |
||
12254 | 650 |
^ self notRunningHolder |
9954 | 651 |
|
652 |
"Created: / 07-09-2010 / 09:15:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
12254 | 653 |
"Modified: / 04-06-2012 / 18:40:46 / cg" |
9954 | 654 |
! |
655 |
||
656 |
runEnabledHolder |
|
657 |
^BlockValue |
|
658 |
with: |
|
12254 | 659 |
[:result :running | |
660 |
||
661 |
running not |
|
662 |
and:[ result notNil |
|
663 |
and:[ result testCount > 0 ]] |
|
664 |
] |
|
9954 | 665 |
argument: self resultHolder |
12254 | 666 |
argument: self runningHolder |
9954 | 667 |
|
668 |
"Created: / 07-09-2010 / 09:15:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
12254 | 669 |
"Modified: / 04-06-2012 / 18:52:41 / cg" |
670 |
! |
|
671 |
||
672 |
runFailedEnabledHolder |
|
673 |
^BlockValue |
|
674 |
with: |
|
675 |
[:running | |
|
676 |
||
677 |
|result| |
|
678 |
||
679 |
result := (self resultForSuite:self suiteForRunAll). |
|
680 |
running not |
|
681 |
and:[ result notNil |
|
682 |
and:[ result hasFailuresOrErrors ]] |
|
683 |
] |
|
684 |
"/ argument: self resultHolder |
|
685 |
argument: self runningHolder |
|
686 |
||
687 |
"Created: / 07-09-2010 / 09:15:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
688 |
"Created: / 04-06-2012 / 18:28:12 / cg" |
|
9954 | 689 |
! |
690 |
||
691 |
runningHolder |
|
692 |
runningHolder isNil ifTrue:[ |
|
693 |
runningHolder := ValueHolder with: false. |
|
694 |
]. |
|
695 |
^ runningHolder |
|
696 |
||
697 |
"Modified: / 15-03-2010 / 20:29:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
12254 | 698 |
"Modified (comment): / 04-06-2012 / 18:38:52 / cg" |
9954 | 699 |
! |
700 |
||
701 |
selectedClassesHolder |
|
702 |
"return/create the 'selectedClassesHolder' value holder (automatically generated)" |
|
703 |
||
704 |
selectedClassesHolder isNil ifTrue:[ |
|
705 |
selectedClassesHolder := ValueHolder new. |
|
706 |
selectedClassesHolder addDependent:self. |
|
707 |
]. |
|
708 |
^ selectedClassesHolder |
|
709 |
! |
|
710 |
||
711 |
selectedClassesHolder:something |
|
712 |
"set the 'selectedClassesHolder' value holder (automatically generated)" |
|
713 |
||
714 |
|oldValue newValue| |
|
715 |
||
716 |
selectedClassesHolder notNil ifTrue:[ |
|
717 |
oldValue := selectedClassesHolder value. |
|
718 |
selectedClassesHolder removeDependent:self. |
|
719 |
]. |
|
720 |
selectedClassesHolder := something. |
|
721 |
selectedClassesHolder notNil ifTrue:[ |
|
722 |
selectedClassesHolder addDependent:self. |
|
723 |
]. |
|
724 |
newValue := selectedClassesHolder value. |
|
725 |
oldValue ~~ newValue ifTrue:[ |
|
726 |
self update:#value with:newValue from:selectedClassesHolder. |
|
727 |
]. |
|
728 |
! |
|
729 |
||
730 |
selectedMethodsHolder |
|
731 |
"return/create the 'selectedMethodsHolder' value holder (automatically generated)" |
|
732 |
||
733 |
selectedMethodsHolder isNil ifTrue:[ |
|
734 |
selectedMethodsHolder := ValueHolder new. |
|
735 |
selectedMethodsHolder addDependent:self. |
|
736 |
]. |
|
737 |
^ selectedMethodsHolder |
|
738 |
! |
|
739 |
||
740 |
selectedMethodsHolder:something |
|
741 |
"set the 'selectedMethodsHolder' value holder (automatically generated)" |
|
742 |
||
743 |
|oldValue newValue| |
|
744 |
||
745 |
selectedMethodsHolder notNil ifTrue:[ |
|
746 |
oldValue := selectedMethodsHolder value. |
|
747 |
selectedMethodsHolder removeDependent:self. |
|
748 |
]. |
|
749 |
selectedMethodsHolder := something. |
|
750 |
selectedMethodsHolder notNil ifTrue:[ |
|
751 |
selectedMethodsHolder addDependent:self. |
|
752 |
]. |
|
753 |
newValue := selectedMethodsHolder value. |
|
754 |
oldValue ~~ newValue ifTrue:[ |
|
755 |
self update:#value with:newValue from:selectedMethodsHolder. |
|
756 |
]. |
|
757 |
! |
|
758 |
||
759 |
selectedProtocolsHolder |
|
760 |
"return/create the 'selectedProtocolsHolder' value holder (automatically generated)" |
|
761 |
||
762 |
selectedProtocolsHolder isNil ifTrue:[ |
|
763 |
selectedProtocolsHolder := ValueHolder new. |
|
764 |
selectedProtocolsHolder addDependent:self. |
|
765 |
]. |
|
766 |
^ selectedProtocolsHolder |
|
767 |
! |
|
768 |
||
769 |
selectedProtocolsHolder:something |
|
770 |
"set the 'selectedProtocolsHolder' value holder (automatically generated)" |
|
771 |
||
772 |
|oldValue newValue| |
|
773 |
||
774 |
selectedProtocolsHolder notNil ifTrue:[ |
|
775 |
oldValue := selectedProtocolsHolder value. |
|
776 |
selectedProtocolsHolder removeDependent:self. |
|
777 |
]. |
|
778 |
selectedProtocolsHolder := something. |
|
779 |
selectedProtocolsHolder notNil ifTrue:[ |
|
780 |
selectedProtocolsHolder addDependent:self. |
|
781 |
]. |
|
782 |
newValue := selectedProtocolsHolder value. |
|
783 |
oldValue ~~ newValue ifTrue:[ |
|
784 |
self update:#value with:newValue from:selectedProtocolsHolder. |
|
785 |
]. |
|
12254 | 786 |
! |
787 |
||
788 |
stopEnabledHolder |
|
789 |
^ self runningHolder |
|
790 |
||
791 |
"Created: / 04-06-2012 / 18:29:01 / cg" |
|
9954 | 792 |
! ! |
793 |
||
794 |
!TestRunnerEmbedded methodsFor:'change & update'! |
|
795 |
||
796 |
update:aspect with:param from: sender |
|
797 |
"Invoked when an object that I depend upon sends a change notification." |
|
798 |
||
799 |
sender == selectedClassesHolder ifTrue:[ |
|
800 |
self |
|
801 |
updateTestCases; |
|
802 |
updateTestSuiteAndResult; |
|
803 |
updateVisibility. |
|
804 |
^ self. |
|
805 |
]. |
|
806 |
sender == selectedProtocolsHolder ifTrue:[ |
|
807 |
self updateTestSuiteAndResult. |
|
808 |
^self |
|
809 |
]. |
|
810 |
||
811 |
sender == selectedMethodsHolder ifTrue:[ |
|
812 |
self updateTestSuiteAndResult. |
|
813 |
^self |
|
814 |
]. |
|
815 |
sender == methodGeneratorHolder ifTrue:[ |
|
816 |
self updateTestSuiteAndResult. |
|
817 |
^self |
|
818 |
]. |
|
819 |
||
12125 | 820 |
sender == Smalltalk ifTrue:[ |
821 |
aspect == #lastTestRunResult ifTrue:[ |
|
12254 | 822 |
(allTestCases includesIdentical: param first) ifTrue:[ |
12125 | 823 |
self updateTestSuiteAndResult. |
824 |
^self |
|
825 |
] |
|
826 |
] |
|
827 |
]. |
|
828 |
||
9954 | 829 |
|
830 |
||
831 |
super update:aspect with:param from: sender |
|
832 |
||
12125 | 833 |
"Modified: / 20-11-2011 / 12:40:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
12254 | 834 |
"Modified: / 04-06-2012 / 19:03:34 / cg" |
9954 | 835 |
! |
836 |
||
837 |
updateTestCases |
|
12254 | 838 |
allTestCases := ((self selectedClassesHolder value ? #()) |
9954 | 839 |
select:[:cls | self isTestCaseLike:cls ]). |
12254 | 840 |
allTestCases := allTestCases asArray |
9954 | 841 |
|
842 |
"Created: / 11-03-2010 / 10:31:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
12125 | 843 |
"Modified: / 24-01-2012 / 22:09:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
12254 | 844 |
"Modified: / 04-06-2012 / 19:02:52 / cg" |
9954 | 845 |
! |
846 |
||
847 |
updateTestSuiteAndResult |
|
848 |
||
849 |
| suite suiteAndResult | |
|
850 |
self runningHolder value ifTrue:[^self]. |
|
12254 | 851 |
allTestCases isEmptyOrNil ifTrue:[^self]. |
9954 | 852 |
suiteAndResult := SuiteAndResult |
853 |
suite: (suite := self suiteForRun) |
|
854 |
result: (self resultForSuite: suite). |
|
855 |
self resultHolder value: suiteAndResult. |
|
856 |
||
857 |
"Created: / 15-03-2010 / 19:41:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
858 |
"Modified: / 15-03-2010 / 20:55:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
12254 | 859 |
"Modified: / 04-06-2012 / 19:03:15 / cg" |
9954 | 860 |
! |
861 |
||
862 |
updateVisibility |
|
863 |
||
864 |
self hasTestCaseSelected |
|
865 |
ifTrue:[self show] |
|
866 |
ifFalse:[self hide] |
|
867 |
||
868 |
"Created: / 11-03-2010 / 09:02:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
869 |
! ! |
|
870 |
||
871 |
!TestRunnerEmbedded methodsFor:'hooks'! |
|
872 |
||
12125 | 873 |
commonPostOpen |
874 |
||
875 |
Smalltalk addDependent: self. |
|
876 |
||
877 |
"Created: / 17-11-2011 / 20:59:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
878 |
! |
|
879 |
||
9954 | 880 |
postBuildRunnerPanel: aView |
881 |
||
882 |
runnerPanel := aView. |
|
883 |
runnerPanel backgroundColor: self resultBackgroundColorAspect value |
|
884 |
||
885 |
"Created: / 15-03-2010 / 14:26:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
12125 | 886 |
! |
887 |
||
888 |
releaseAsSubCanvas |
|
889 |
||
890 |
Smalltalk removeDependent: self. |
|
891 |
||
892 |
"Created: / 17-11-2011 / 21:03:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
9954 | 893 |
! ! |
894 |
||
895 |
!TestRunnerEmbedded methodsFor:'private'! |
|
896 |
||
897 |
hide |
|
898 |
||
899 |
self visibility: false height: 0 |
|
900 |
||
901 |
"Created: / 11-03-2010 / 09:07:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
902 |
! |
|
903 |
||
904 |
isTestCaseLike:cls |
|
905 |
||
906 |
^(super isTestCaseLike: cls) and: |
|
907 |
[(cls askFor: #isAbstract) not] |
|
908 |
||
909 |
"Modified: / 04-03-2011 / 06:54:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
910 |
! |
|
911 |
||
912 |
show |
|
913 |
||
914 |
self visibility: true height: 50 |
|
915 |
||
916 |
"Created: / 11-03-2010 / 09:07:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
917 |
! |
|
918 |
||
10564
4e109c7b8ee8
comment/format in: #visibility:height:
Claus Gittinger <cg@exept.de>
parents:
10563
diff
changeset
|
919 |
visibility:visibility height:height |
4e109c7b8ee8
comment/format in: #visibility:height:
Claus Gittinger <cg@exept.de>
parents:
10563
diff
changeset
|
920 |
|container list h| |
9954 | 921 |
|
10564
4e109c7b8ee8
comment/format in: #visibility:height:
Claus Gittinger <cg@exept.de>
parents:
10563
diff
changeset
|
922 |
(container := self window container) ifNil:[ ^ self ]. |
4e109c7b8ee8
comment/format in: #visibility:height:
Claus Gittinger <cg@exept.de>
parents:
10563
diff
changeset
|
923 |
h := visibility ifFalse:[0] ifTrue:[ height ]. |
4e109c7b8ee8
comment/format in: #visibility:height:
Claus Gittinger <cg@exept.de>
parents:
10563
diff
changeset
|
924 |
container isVisible == visibility ifFalse:[ |
4e109c7b8ee8
comment/format in: #visibility:height:
Claus Gittinger <cg@exept.de>
parents:
10563
diff
changeset
|
925 |
container isVisible:visibility |
4e109c7b8ee8
comment/format in: #visibility:height:
Claus Gittinger <cg@exept.de>
parents:
10563
diff
changeset
|
926 |
]. |
9954 | 927 |
list := container container subViews first. |
10564
4e109c7b8ee8
comment/format in: #visibility:height:
Claus Gittinger <cg@exept.de>
parents:
10563
diff
changeset
|
928 |
(list layout bottomOffset ~= height negated) ifTrue:[ |
4e109c7b8ee8
comment/format in: #visibility:height:
Claus Gittinger <cg@exept.de>
parents:
10563
diff
changeset
|
929 |
list layout:((list layout) |
4e109c7b8ee8
comment/format in: #visibility:height:
Claus Gittinger <cg@exept.de>
parents:
10563
diff
changeset
|
930 |
bottomOffset:height negated; |
4e109c7b8ee8
comment/format in: #visibility:height:
Claus Gittinger <cg@exept.de>
parents:
10563
diff
changeset
|
931 |
yourself) |
4e109c7b8ee8
comment/format in: #visibility:height:
Claus Gittinger <cg@exept.de>
parents:
10563
diff
changeset
|
932 |
]. |
9954 | 933 |
|
934 |
"Created: / 11-03-2010 / 09:51:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
935 |
! ! |
|
936 |
||
937 |
!TestRunnerEmbedded methodsFor:'queries'! |
|
938 |
||
939 |
hasTestCaseSelected |
|
940 |
||
12254 | 941 |
^allTestCases notEmptyOrNil |
9954 | 942 |
|
943 |
"Created: / 11-03-2010 / 09:06:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
944 |
"Modified: / 15-03-2010 / 20:54:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10454 | 945 |
"Modified: / 04-08-2011 / 20:42:10 / cg" |
9954 | 946 |
! ! |
947 |
||
948 |
!TestRunnerEmbedded methodsFor:'utilities'! |
|
949 |
||
10432 | 950 |
resultForSuite:suite |
951 |
|result| |
|
9954 | 952 |
|
953 |
result := TestResult new. |
|
10432 | 954 |
suite tests do:[:test | |
12125 | 955 |
| sel cls | |
10432 | 956 |
|
957 |
sel := test selector. |
|
12125 | 958 |
cls := test class. |
959 |
(cls testSelectorPassed:sel) ifTrue:[ |
|
960 |
result passedOutcomes add: (cls rememberedOutcomeFor: sel) |
|
10432 | 961 |
] ifFalse:[ |
12125 | 962 |
(cls testSelectorError:sel) ifTrue:[ |
963 |
result errorOutcomes add:(cls rememberedOutcomeFor: sel) |
|
10432 | 964 |
] ifFalse:[ |
12125 | 965 |
(cls testSelectorFailed:sel) ifTrue:[ |
966 |
result failureOutcomes add:(cls rememberedOutcomeFor: sel) |
|
10432 | 967 |
] |
968 |
] |
|
969 |
] |
|
970 |
]. |
|
971 |
^ result |
|
9954 | 972 |
|
973 |
"Created: / 15-03-2010 / 19:46:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10432 | 974 |
"Modified: / 02-08-2011 / 18:20:00 / cg" |
12125 | 975 |
"Modified: / 20-08-2011 / 14:30:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9954 | 976 |
! |
977 |
||
978 |
suiteForRun |
|
10374 | 979 |
| methods protocols suite selectedClass | |
980 |
||
981 |
selectedClass := self theSingleTestCase. |
|
10563
f77d63752e6a
comment/format in: #suiteForRunAll
Claus Gittinger <cg@exept.de>
parents:
10454
diff
changeset
|
982 |
(methods := selectedMethodsHolder value) notEmptyOrNil ifTrue:[ |
f77d63752e6a
comment/format in: #suiteForRunAll
Claus Gittinger <cg@exept.de>
parents:
10454
diff
changeset
|
983 |
suite := TestSuite named: (self suiteNameFromMethods: methods). |
f77d63752e6a
comment/format in: #suiteForRunAll
Claus Gittinger <cg@exept.de>
parents:
10454
diff
changeset
|
984 |
self selectedTestMethods do:[:mthd| |
f77d63752e6a
comment/format in: #suiteForRunAll
Claus Gittinger <cg@exept.de>
parents:
10454
diff
changeset
|
985 |
| class selector | |
10374 | 986 |
class := selectedClass ifNil:[mthd mclass]. |
10563
f77d63752e6a
comment/format in: #suiteForRunAll
Claus Gittinger <cg@exept.de>
parents:
10454
diff
changeset
|
987 |
suite addTest: (class asTestCase selector: mthd selector) |
f77d63752e6a
comment/format in: #suiteForRunAll
Claus Gittinger <cg@exept.de>
parents:
10454
diff
changeset
|
988 |
]. |
f77d63752e6a
comment/format in: #suiteForRunAll
Claus Gittinger <cg@exept.de>
parents:
10454
diff
changeset
|
989 |
^suite |
f77d63752e6a
comment/format in: #suiteForRunAll
Claus Gittinger <cg@exept.de>
parents:
10454
diff
changeset
|
990 |
]. |
9954 | 991 |
|
10563
f77d63752e6a
comment/format in: #suiteForRunAll
Claus Gittinger <cg@exept.de>
parents:
10454
diff
changeset
|
992 |
(protocols := selectedProtocolsHolder value) isEmptyOrNil ifFalse:[ |
f77d63752e6a
comment/format in: #suiteForRunAll
Claus Gittinger <cg@exept.de>
parents:
10454
diff
changeset
|
993 |
suite := TestSuite named: (self suiteNameFromProtocols: protocols). |
f77d63752e6a
comment/format in: #suiteForRunAll
Claus Gittinger <cg@exept.de>
parents:
10454
diff
changeset
|
994 |
(self selectedTestMethodsFromProtocols: protocols) do:[:mthd| |
f77d63752e6a
comment/format in: #suiteForRunAll
Claus Gittinger <cg@exept.de>
parents:
10454
diff
changeset
|
995 |
| class selector | |
10374 | 996 |
class := selectedClass ifNil:[mthd mclass]. |
10563
f77d63752e6a
comment/format in: #suiteForRunAll
Claus Gittinger <cg@exept.de>
parents:
10454
diff
changeset
|
997 |
suite addTest: (mthd mclass asTestCase selector: mthd selector) |
f77d63752e6a
comment/format in: #suiteForRunAll
Claus Gittinger <cg@exept.de>
parents:
10454
diff
changeset
|
998 |
]. |
f77d63752e6a
comment/format in: #suiteForRunAll
Claus Gittinger <cg@exept.de>
parents:
10454
diff
changeset
|
999 |
^suite |
f77d63752e6a
comment/format in: #suiteForRunAll
Claus Gittinger <cg@exept.de>
parents:
10454
diff
changeset
|
1000 |
]. |
10374 | 1001 |
|
9954 | 1002 |
^self suiteForRunAll |
1003 |
||
1004 |
"Created: / 15-03-2010 / 13:13:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10374 | 1005 |
"Modified: / 22-07-2011 / 15:48:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10454 | 1006 |
"Modified: / 04-08-2011 / 19:06:42 / cg" |
9954 | 1007 |
! |
1008 |
||
1009 |
suiteForRunAll |
|
1010 |
|suite| |
|
12254 | 1011 |
suite := TestSuite named:(self suiteNameFromClasses: allTestCases). |
1012 |
allTestCases isNil ifTrue:[ |
|
1013 |
self updateTestCases. |
|
1014 |
]. |
|
1015 |
||
1016 |
allTestCases do:[:testCase | |
|
10563
f77d63752e6a
comment/format in: #suiteForRunAll
Claus Gittinger <cg@exept.de>
parents:
10454
diff
changeset
|
1017 |
suite addTests:(self buildSuiteFromClass:testCase) tests |
f77d63752e6a
comment/format in: #suiteForRunAll
Claus Gittinger <cg@exept.de>
parents:
10454
diff
changeset
|
1018 |
]. |
9954 | 1019 |
^suite |
1020 |
||
1021 |
"Modified: / 04-03-2011 / 06:57:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
12254 | 1022 |
"Modified: / 04-06-2012 / 19:01:48 / cg" |
1023 |
! |
|
1024 |
||
1025 |
suiteForRunFailed |
|
1026 |
|suite| |
|
1027 |
||
1028 |
suite := TestSuite named:(self suiteNameFromClasses: allTestCases). |
|
1029 |
allTestCases do:[:testCase | |
|
1030 |
(self buildSuiteFromClass:testCase) tests do:[:eachTest | |
|
1031 |
| sel cls | |
|
1032 |
||
1033 |
sel := eachTest selector. |
|
1034 |
cls := eachTest class. |
|
1035 |
(cls testSelectorPassed:sel) ifFalse:[ |
|
1036 |
suite addTest:eachTest |
|
1037 |
] |
|
1038 |
] |
|
1039 |
]. |
|
1040 |
^suite |
|
1041 |
||
1042 |
"Modified: / 04-03-2011 / 06:57:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1043 |
"Created: / 04-06-2012 / 18:32:40 / cg" |
|
9954 | 1044 |
! ! |
1045 |
||
1046 |
!TestRunnerEmbedded::SuiteAndResult class methodsFor:'instance creation'! |
|
1047 |
||
1048 |
suite: suite result: result |
|
1049 |
||
1050 |
^self new |
|
1051 |
suite: suite; |
|
1052 |
result: result. |
|
1053 |
||
1054 |
"Modified: / 15-03-2010 / 15:27:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1055 |
! ! |
|
1056 |
||
1057 |
!TestRunnerEmbedded::SuiteAndResult methodsFor:'accessing'! |
|
1058 |
||
1059 |
color |
|
1060 |
||
1061 |
self testCount == 0 ifTrue: |
|
1062 |
[^TestRunnerEmbedded notRunColor]. |
|
1063 |
||
1064 |
result ifNil:[^TestRunnerEmbedded notRunColor]. |
|
1065 |
self hasErrors ifTrue:[^TestRunnerEmbedded errorColor]. |
|
1066 |
self hasFailures ifTrue:[^TestRunnerEmbedded failedColor]. |
|
1067 |
self hasPassed ifTrue:[^TestRunnerEmbedded passedColor]. |
|
1068 |
^TestRunnerEmbedded notRunColor |
|
1069 |
||
1070 |
"Created: / 15-03-2010 / 15:24:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1071 |
"Modified: / 07-09-2010 / 08:25:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1072 |
! |
|
1073 |
||
1074 |
info |
|
1075 |
||
1076 |
result ifNil:[^'']. |
|
1077 |
(result passedCount + result failureCount + result errorCount) = 1 ifTrue:[^'']. |
|
1078 |
^'%1 tests, %2 passed, %3 failed, %4 errors' |
|
1079 |
bindWith: suite tests size |
|
1080 |
with: result passedCount |
|
1081 |
with: result failureCount |
|
1082 |
with: result errorCount |
|
1083 |
||
1084 |
"Created: / 15-03-2010 / 20:23:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1085 |
! |
|
1086 |
||
1087 |
name |
|
1088 |
||
1089 |
^suite name |
|
1090 |
||
1091 |
"Created: / 15-03-2010 / 15:12:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1092 |
! |
|
1093 |
||
1094 |
result |
|
1095 |
^ result |
|
1096 |
! |
|
1097 |
||
1098 |
result:aTestResult |
|
1099 |
result := aTestResult. |
|
1100 |
! |
|
1101 |
||
1102 |
suite |
|
1103 |
^ suite |
|
1104 |
! |
|
1105 |
||
1106 |
suite:aTestSuite |
|
1107 |
suite := aTestSuite. |
|
1108 |
! |
|
1109 |
||
12125 | 1110 |
suiteForRun |
1111 |
||
1112 |
| suiteForRun | |
|
1113 |
suiteForRun := suite class named: suite name. |
|
1114 |
suiteForRun addTests: |
|
1115 |
(suite tests collect:[:testCase|testCase class selector: testCase selector]). |
|
1116 |
^suiteForRun |
|
1117 |
||
1118 |
"Created: / 22-08-2011 / 09:56:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1119 |
! |
|
1120 |
||
9954 | 1121 |
testCount |
1122 |
||
1123 |
^suite tests size |
|
1124 |
||
1125 |
"Created: / 15-03-2010 / 15:44:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1126 |
! ! |
|
1127 |
||
1128 |
!TestRunnerEmbedded::SuiteAndResult methodsFor:'queries'! |
|
1129 |
||
1130 |
hasErrors |
|
1131 |
||
1132 |
^result errorCount > 0 |
|
1133 |
||
1134 |
"Created: / 15-03-2010 / 15:21:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1135 |
! |
|
1136 |
||
1137 |
hasFailures |
|
1138 |
||
1139 |
^result failureCount > 0 |
|
1140 |
||
1141 |
"Created: / 15-03-2010 / 15:21:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1142 |
! |
|
1143 |
||
1144 |
hasFailuresOrErrors |
|
1145 |
||
1146 |
^self hasErrors or:[self hasFailures] |
|
1147 |
||
1148 |
"Created: / 15-03-2010 / 15:45:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1149 |
! |
|
1150 |
||
1151 |
hasPassed |
|
1152 |
||
1153 |
^result passedCount > 0 |
|
1154 |
||
1155 |
"Created: / 15-03-2010 / 22:06:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1156 |
! ! |
|
1157 |
||
1158 |
!TestRunnerEmbedded class methodsFor:'documentation'! |
|
1159 |
||
10432 | 1160 |
version |
12254 | 1161 |
^ '$Header: /cvs/stx/stx/libtool/Tools__TestRunnerEmbedded.st,v 1.24 2012/06/04 18:12:25 cg Exp $' |
10432 | 1162 |
! |
1163 |
||
9954 | 1164 |
version_CVS |
12254 | 1165 |
^ '§Header: /cvs/stx/stx/libtool/Tools__TestRunnerEmbedded.st,v 1.24 2012/06/04 18:12:25 cg Exp §' |
9954 | 1166 |
! |
1167 |
||
1168 |
version_SVN |
|
12254 | 1169 |
^ '$Id: Tools__TestRunnerEmbedded.st 8007 2012-06-05 14:49:00Z vranyj1 $' |
12125 | 1170 |
! ! |