author | Claus Gittinger <cg@exept.de> |
Wed, 29 May 2019 01:13:02 +0200 | |
changeset 748 | 96c1372d5e54 |
parent 743 | 73d95feec87f |
child 753 | 5052e1bf244a |
permissions | -rw-r--r-- |
739 | 1 |
"{ Encoding: utf8 }" |
2 |
||
0 | 3 |
"{ Package: 'stx:goodies/sunit' }" |
4 |
||
596 | 5 |
"{ NameSpace: Smalltalk }" |
6 |
||
0 | 7 |
Object subclass:#TestResult |
742 | 8 |
instanceVariableNames:'name timestamp failures errors passed skipped outcome lastOutcome |
9 |
endTime' |
|
347 | 10 |
classVariableNames:'DefaultClass' |
104 | 11 |
poolDictionaries:'' |
12 |
category:'SUnit-Base' |
|
13 |
! |
|
14 |
||
222 | 15 |
TestResult comment:'' |
0 | 16 |
! |
17 |
||
336 | 18 |
!TestResult class methodsFor:'documentation'! |
19 |
||
20 |
documentation |
|
21 |
" |
|
22 |
runInfoPerTest: |
|
23 |
will keep additional info for a testCase run: |
|
24 |
startTime, endTime, backtrace (if fail or error) and collectedStdout |
|
25 |
" |
|
26 |
! ! |
|
14 | 27 |
|
222 | 28 |
!TestResult class methodsFor:'instance creation'! |
29 |
||
30 |
new |
|
629 | 31 |
self == TestResult ifTrue:[ |
405 | 32 |
^ self defaultResultClass basicNew initialize. |
33 |
] ifFalse:[ |
|
34 |
^ self basicNew initialize |
|
35 |
]. |
|
347 | 36 |
|
405 | 37 |
" |
38 |
TestResult new. |
|
39 |
TestResultForRunWithDebug new. |
|
40 |
" |
|
41 |
||
42 |
"Modified (comment): / 20-08-2011 / 17:34:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
347 | 43 |
! ! |
44 |
||
45 |
!TestResult class methodsFor:'accessing'! |
|
46 |
||
47 |
defaultResultClass |
|
48 |
DefaultClass notNil ifTrue:[^DefaultClass]. |
|
49 |
||
50 |
((Smalltalk respondsTo: #isSmalltalkX) and:[Smalltalk isSmalltalkX]) ifTrue:[ |
|
51 |
DefaultClass := TestResultStX. |
|
52 |
^DefaultClass |
|
53 |
]. |
|
54 |
"Add more dialects here, if you want..." |
|
55 |
||
56 |
"Default" |
|
57 |
DefaultClass := self. |
|
58 |
||
59 |
"Created: / 16-08-2011 / 15:02:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
222 | 60 |
! ! |
61 |
||
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
62 |
!TestResult class methodsFor:'constants'! |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
63 |
|
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
64 |
stateError |
738 | 65 |
"this symbol used to freak around everywhere in the code" |
66 |
||
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
67 |
^ #error |
738 | 68 |
|
69 |
"Modified (comment): / 28-03-2019 / 11:26:52 / Claus Gittinger" |
|
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
70 |
! |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
71 |
|
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
72 |
stateFail |
574 | 73 |
"this symbol used to freak around everywhere in the code; |
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
74 |
and I was never sure if #fail or #failed is to be used." |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
75 |
|
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
76 |
^ #fail |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
77 |
! |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
78 |
|
738 | 79 |
stateInconclusive |
80 |
"this symbol is currently not used; |
|
81 |
support will be added soon." |
|
82 |
||
83 |
^ #inconclusive |
|
84 |
||
85 |
"Created: / 28-03-2019 / 11:28:32 / Claus Gittinger" |
|
86 |
! |
|
87 |
||
88 |
stateNames |
|
89 |
^ { |
|
90 |
self statePass. |
|
91 |
self stateError. |
|
92 |
self stateFail. |
|
93 |
self stateSkip. |
|
94 |
self stateInconclusive. |
|
95 |
} |
|
96 |
||
97 |
"Created: / 28-03-2019 / 11:27:55 / Claus Gittinger" |
|
98 |
! |
|
99 |
||
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
100 |
statePass |
574 | 101 |
"this symbol used to freak around everywhere in the code; |
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
102 |
and I was never sure if #pass or #passed is to be used." |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
103 |
|
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
104 |
^ #pass |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
105 |
! |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
106 |
|
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
107 |
stateSkip |
738 | 108 |
"this symbol used to freak around everywhere in the code; |
109 |
and I was never sure if #skip or #skipped is to be used." |
|
110 |
||
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
111 |
^ #skip |
738 | 112 |
|
113 |
"Modified (comment): / 28-03-2019 / 11:27:07 / Claus Gittinger" |
|
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
114 |
! ! |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
115 |
|
68 | 116 |
!TestResult class methodsFor:'exceptions'! |
0 | 117 |
|
118 |
error |
|
104 | 119 |
^self exError |
0 | 120 |
! |
121 |
||
122 |
exError |
|
104 | 123 |
^SUnitNameResolver errorObject |
0 | 124 |
! |
125 |
||
126 |
failure |
|
104 | 127 |
^TestFailure |
128 |
! |
|
0 | 129 |
|
104 | 130 |
resumableFailure |
131 |
^ResumableTestFailure |
|
0 | 132 |
! |
133 |
||
222 | 134 |
signalErrorWith: aString |
135 |
self error sunitSignalWith: aString |
|
136 |
! |
|
0 | 137 |
|
222 | 138 |
signalFailureWith: aString |
139 |
self failure sunitSignalWith: aString |
|
549 | 140 |
! |
141 |
||
142 |
skipped |
|
143 |
^ TestSkipped |
|
0 | 144 |
! ! |
145 |
||
501 | 146 |
!TestResult class methodsFor:'utilities'! |
147 |
||
148 |
sourceFilenameOfClass:aClass |
|
149 |
^ nil |
|
150 |
||
151 |
" use something like... " |
|
152 |
" ^ aClass classFilename asFilename pathName. " |
|
153 |
! ! |
|
154 |
||
68 | 155 |
!TestResult methodsFor:'accessing'! |
0 | 156 |
|
157 |
defects |
|
104 | 158 |
^OrderedCollection new |
159 |
addAll: self errors; |
|
160 |
addAll: self failures; yourself |
|
0 | 161 |
! |
162 |
||
742 | 163 |
endTime |
164 |
"get the overall (suite) end time; |
|
165 |
nil if not yet finished" |
|
166 |
||
167 |
^ endTime |
|
168 |
||
169 |
"Created: / 28-03-2019 / 13:42:31 / Claus Gittinger" |
|
170 |
! |
|
171 |
||
478 | 172 |
endTime:aTimestamp |
173 |
"sets the overall (suite) end time" |
|
174 |
||
742 | 175 |
endTime := aTimestamp. |
176 |
||
177 |
"Modified: / 28-03-2019 / 13:42:13 / Claus Gittinger" |
|
478 | 178 |
! |
179 |
||
0 | 180 |
errorCount |
104 | 181 |
|
347 | 182 |
^self errorOutcomes size |
183 |
||
184 |
"Modified: / 16-08-2011 / 15:58:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
185 |
! |
|
186 |
||
187 |
errorOutcomes |
|
188 |
||
189 |
errors isNil ifTrue: [errors := OrderedCollection new]. |
|
190 |
^errors |
|
191 |
||
192 |
"Created: / 16-08-2011 / 15:55:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
193 |
! |
0 | 194 |
|
195 |
errors |
|
347 | 196 |
|
447 | 197 |
errors isNil ifTrue: [^OrderedCollection new]. |
198 |
^errors collect:[:each|each testCase] |
|
347 | 199 |
|
447 | 200 |
"Modified (format): / 02-08-2012 / 15:40:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
201 |
! |
0 | 202 |
|
300
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
203 |
exceptions |
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
204 |
|
603 | 205 |
"Returns a set of exceptions to be handled. By default, |
300
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
206 |
failure and generic error is handled. This method may |
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
207 |
be overriden by custom TestResult subclasses to add more. |
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
208 |
For example, a 'self halt' is not handled by default |
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
209 |
exceptions set" |
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
210 |
|
642 | 211 |
^self class failure , self class skipped , self class error |
300
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
212 |
|
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
213 |
"Created: / 03-08-2011 / 14:11:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
214 |
! |
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
215 |
|
481 | 216 |
executionTime |
217 |
"return the execution time (in seconds). |
|
218 |
If unknown, or asked before or during a run, return nil" |
|
219 |
||
742 | 220 |
timestamp isNil ifTrue:[^ nil]. |
221 |
endTime isNil ifTrue:[^ nil]. |
|
222 |
^ endTime secondDeltaFrom:timestamp |
|
223 |
||
224 |
"Modified: / 28-03-2019 / 13:43:57 / Claus Gittinger" |
|
481 | 225 |
! |
226 |
||
0 | 227 |
failureCount |
228 |
||
347 | 229 |
^self failureOutcomes size |
230 |
||
231 |
"Modified: / 16-08-2011 / 15:58:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
232 |
! |
|
233 |
||
234 |
failureOutcomes |
|
235 |
||
236 |
failures isNil ifTrue: [failures := Set new]. |
|
237 |
^failures |
|
238 |
||
239 |
"Created: / 16-08-2011 / 15:56:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
0 | 240 |
! |
241 |
||
242 |
failures |
|
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
243 |
"We use a Set, not an OrderedCollection as #errors and #passed do, |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
244 |
because a resumable test failure in a loop can raise many failures against the same test. |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
245 |
In current Sunit UIs, this could result in bizarre test count reporting (-27 tests run, and suchlike). |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
246 |
This will be reviewed." |
222 | 247 |
|
447 | 248 |
failures isNil ifTrue: [^OrderedCollection new]. |
249 |
^failures collect:[:each|each testCase] |
|
347 | 250 |
|
447 | 251 |
"Modified (format): / 02-08-2012 / 14:55:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
222 | 252 |
! |
253 |
||
254 |
name |
|
255 |
^ name |
|
256 |
! |
|
257 |
||
258 |
name:aString |
|
259 |
name := aString. |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
260 |
! |
0 | 261 |
|
418 | 262 |
outcomes |
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
263 |
|all| |
418 | 264 |
|
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
265 |
all := OrderedCollection new. |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
266 |
self outcomesDo:[:each | all add:each]. |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
267 |
^ all. |
418 | 268 |
! |
269 |
||
270 |
outcomesDo: aBlock |
|
271 |
||
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
272 |
skipped notNil ifTrue:[skipped do: aBlock]. |
418 | 273 |
failures notNil ifTrue:[failures do: aBlock]. |
274 |
errors notNil ifTrue:[errors do: aBlock]. |
|
275 |
passed notNil ifTrue:[passed do: aBlock]. |
|
276 |
||
277 |
"Created: / 20-08-2011 / 14:01:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
278 |
! |
|
279 |
||
739 | 280 |
overallOutcome |
281 |
"returns a verdict as symbol; |
|
282 |
one of error, fail, pass, skip or notRun" |
|
283 |
||
284 |
self hasErrors ifTrue:[^ #error]. |
|
285 |
self hasFailures ifTrue:[^ #fail]. |
|
286 |
self hasPassed ifTrue:[^ #pass]. |
|
287 |
self hasSkipped ifTrue:[^ #skip]. |
|
288 |
^ #notRun |
|
289 |
||
290 |
"Created: / 28-03-2019 / 13:35:19 / Claus Gittinger" |
|
291 |
! |
|
292 |
||
53 | 293 |
passed |
434 | 294 |
passed isNil ifTrue: [ |
295 |
"/ cg: exposed and added to (see TestRunnerEmbedded>>debug) |
|
296 |
passed := OrderedCollection new. |
|
297 |
^ passed. |
|
298 |
]. |
|
447 | 299 |
^passed collect:[:each|each testCase] |
347 | 300 |
|
301 |
"Modified: / 16-08-2011 / 15:54:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
434 | 302 |
"Modified: / 07-11-2011 / 11:19:57 / cg" |
447 | 303 |
"Modified (format): / 02-08-2012 / 14:55:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
53 | 304 |
! |
305 |
||
306 |
passedCount |
|
307 |
||
347 | 308 |
^self passedOutcomes size |
309 |
||
310 |
"Modified: / 16-08-2011 / 15:58:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
311 |
! |
|
312 |
||
313 |
passedOutcomes |
|
314 |
||
315 |
passed isNil ifTrue: [passed := OrderedCollection new]. |
|
316 |
^passed |
|
317 |
||
318 |
"Created: / 16-08-2011 / 15:56:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
53 | 319 |
! |
320 |
||
0 | 321 |
runCount |
53 | 322 |
|
104 | 323 |
^self passedCount + self failureCount + self errorCount |
53 | 324 |
! |
325 |
||
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
326 |
skipped |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
327 |
skipped isNil ifTrue: [ |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
328 |
"/ cg: exposed and added to (see TestRunnerEmbedded>>debug) |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
329 |
skipped := OrderedCollection new. |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
330 |
^ skipped. |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
331 |
]. |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
332 |
^skipped collect:[:each|each testCase] |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
333 |
! |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
334 |
|
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
335 |
skippedCount |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
336 |
|
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
337 |
^self skippedOutcomes size |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
338 |
! |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
339 |
|
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
340 |
skippedOutcomes |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
341 |
|
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
342 |
skipped isNil ifTrue: [skipped := OrderedCollection new]. |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
343 |
^skipped |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
344 |
! |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
345 |
|
347 | 346 |
testOutcomes |
347 |
||
348 |
^(OrderedCollection new: self runCount) |
|
349 |
addAll: self passedOutcomes; |
|
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
350 |
addAll: self skippedOutcomes; |
347 | 351 |
addAll: self errorOutcomes; |
352 |
addAll: self failureOutcomes; |
|
353 |
yourself |
|
354 |
||
355 |
"Created: / 16-08-2011 / 16:42:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
356 |
! |
|
357 |
||
53 | 358 |
tests |
104 | 359 |
|
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
360 |
^(OrderedCollection new: self runCount) |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
361 |
addAll: self passed; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
362 |
addAll: self skipped; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
363 |
addAll: self errors; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
364 |
addAll: self failures; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
365 |
yourself |
222 | 366 |
! |
367 |
||
368 |
timestamp |
|
742 | 369 |
"get the start time" |
370 |
||
222 | 371 |
^ timestamp |
742 | 372 |
|
373 |
"Modified (comment): / 28-03-2019 / 13:41:53 / Claus Gittinger" |
|
270 | 374 |
! |
375 |
||
478 | 376 |
timestamp:aTimestamp |
742 | 377 |
"sets the start time" |
378 |
||
478 | 379 |
timestamp := aTimestamp. |
742 | 380 |
|
381 |
"Modified (comment): / 28-03-2019 / 13:41:47 / Claus Gittinger" |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
382 |
! ! |
0 | 383 |
|
438 | 384 |
!TestResult methodsFor:'adding / removing'! |
222 | 385 |
|
347 | 386 |
addError:testcase detail:detail |
676 | 387 |
"Called when a test outcome is error. testCase |
388 |
is the erroneous testcase, detail is platform |
|
347 | 389 |
specific object describing the error. Actually, |
676 | 390 |
on all platforms except GemStone, detail is an instance |
347 | 391 |
of an exception that caused the error" |
392 |
"JV2011-08-03: TODO: Validate the comment above with GS, |
|
393 |
possibly change name to 'exception'" |
|
300
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
394 |
|
418 | 395 |
|
525 | 396 |
outcome result: (TestResult stateError). |
418 | 397 |
outcome remember. |
347 | 398 |
^ self errorOutcomes add:outcome. |
300
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
399 |
|
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
400 |
"Created: / 03-08-2011 / 13:50:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
318
96ce5904bba6
added: #rememberException:detail:
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
401 |
"Modified: / 06-08-2011 / 09:46:41 / cg" |
418 | 402 |
"Modified: / 20-08-2011 / 12:46:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
676 | 403 |
"Modified (comment): / 22-05-2017 / 18:27:02 / mawalch" |
222 | 404 |
! |
405 |
||
676 | 406 |
addFailure:testcase detail:detail |
407 |
"Called when a test fails. testCase is the failed |
|
347 | 408 |
testcase, detail is platform specific object describing |
676 | 409 |
the failure. Actually, on all platforms except GemStone, |
347 | 410 |
detail is an instance of an exception that caused the failure" |
411 |
"JV2011-08-03: TODO: Validate the comment above with GS, |
|
412 |
possibly change name to 'exception'" |
|
418 | 413 |
|
347 | 414 |
"Special handling here, because failures can be resumable" |
676 | 415 |
self failureOutcomes do:[:outcome | |
347 | 416 |
outcome testCase = testcase ifTrue:[ |
417 |
^ self |
|
418 |
]. |
|
419 |
]. |
|
525 | 420 |
outcome result: (TestResult stateFail). |
418 | 421 |
outcome remember. |
347 | 422 |
^ self failureOutcomes add: outcome |
300
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
423 |
|
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
424 |
"Created: / 03-08-2011 / 13:53:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
318
96ce5904bba6
added: #rememberException:detail:
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
425 |
"Modified: / 06-08-2011 / 09:55:17 / cg" |
418 | 426 |
"Modified: / 20-08-2011 / 12:46:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
676 | 427 |
"Modified (comment): / 22-05-2017 / 18:25:30 / mawalch" |
318
96ce5904bba6
added: #rememberException:detail:
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
428 |
! |
96ce5904bba6
added: #rememberException:detail:
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
429 |
|
418 | 430 |
addPass:testCase |
431 |
||
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
432 |
outcome result: (TestResult statePass). |
418 | 433 |
outcome remember. |
347 | 434 |
^ self passedOutcomes add: outcome |
325
76240d956e7d
changed: #rememberExceptionIn:detail:
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
435 |
|
418 | 436 |
"Modified: / 20-08-2011 / 12:44:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
438 | 437 |
! |
438 |
||
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
439 |
addSkipped:testCase |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
440 |
|
525 | 441 |
outcome result: (TestResult stateSkip). |
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
442 |
outcome remember. |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
443 |
^ self skippedOutcomes add: outcome |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
444 |
! |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
445 |
|
438 | 446 |
remove: aTestCase |
447 |
"Removes an outcome for given testcase, if any. |
|
448 |
Use with care." |
|
449 |
||
450 |
| remover | |
|
451 |
||
452 |
remover := [:outcomes| |
|
453 |
| o | |
|
454 |
||
455 |
outcomes notNil ifTrue:[ |
|
456 |
o := outcomes detect:[:each|each testCase == aTestCase] ifNone: [nil]. |
|
457 |
o notNil ifTrue:[outcomes remove: o. ^self]. |
|
458 |
]. |
|
459 |
]. |
|
460 |
||
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
461 |
remover value: skipped. |
438 | 462 |
remover value: errors. |
463 |
remover value: failures. |
|
464 |
remover value: passed. |
|
465 |
||
466 |
"Created: / 16-01-2012 / 20:36:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
222 | 467 |
! ! |
468 |
||
469 |
!TestResult methodsFor:'deprecated'! |
|
470 |
||
471 |
correctCount |
|
472 |
"deprecated - use #passedCount" |
|
473 |
||
474 |
^self passedCount |
|
475 |
! ! |
|
476 |
||
477 |
!TestResult methodsFor:'initialize-release'! |
|
0 | 478 |
|
479 |
initialize |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
480 |
! ! |
0 | 481 |
|
347 | 482 |
!TestResult methodsFor:'outcome'! |
483 |
||
484 |
createOutcome |
|
485 |
||
486 |
^TestCaseOutcome new. |
|
0 | 487 |
|
347 | 488 |
"Created: / 16-08-2011 / 17:14:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
489 |
! |
|
297
87eb8f911bcf
changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents:
292
diff
changeset
|
490 |
|
738 | 491 |
lastOutcome |
492 |
"the outcome of the last executed case |
|
493 |
(only valid in the run...after:[] block)" |
|
494 |
||
495 |
^ lastOutcome. |
|
496 |
||
497 |
"Created: / 28-03-2019 / 11:21:21 / Claus Gittinger" |
|
498 |
! |
|
499 |
||
347 | 500 |
rememberEndTime |
743 | 501 |
"remembers the endTime of the current test" |
347 | 502 |
|
743 | 503 |
endTime := Timestamp now |
292 | 504 |
|
347 | 505 |
"Created: / 16-08-2011 / 17:31:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
743 | 506 |
"Modified (comment): / 28-03-2019 / 13:44:56 / Claus Gittinger" |
347 | 507 |
! |
508 |
||
509 |
rememberException:detail |
|
510 |
||
511 |
"Created: / 16-08-2011 / 17:35:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
512 |
! |
|
292 | 513 |
|
347 | 514 |
rememberStartTime |
478 | 515 |
"remembers the startTime of the current test (in outcome)" |
347 | 516 |
|
517 |
^nil |
|
292 | 518 |
|
347 | 519 |
"Created: / 16-08-2011 / 17:31:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
520 |
! ! |
|
521 |
||
522 |
!TestResult methodsFor:'printing'! |
|
292 | 523 |
|
0 | 524 |
printOn: aStream |
104 | 525 |
|
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
526 |
aStream |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
527 |
nextPutAll: self runCount printString; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
528 |
nextPutAll: ' run, '; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
529 |
nextPutAll: self passedCount printString; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
530 |
nextPutAll: ' passed, '; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
531 |
nextPutAll: self skippedCount printString; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
532 |
nextPutAll: ' skipped, '; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
533 |
nextPutAll: self failureCount printString; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
534 |
nextPutAll: ' failed, '; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
535 |
nextPutAll: self errorCount printString; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
536 |
nextPutAll: ' error'. |
104 | 537 |
|
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
538 |
self errorCount ~= 1 |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
539 |
ifTrue: [aStream nextPut: $s] |
0 | 540 |
! ! |
541 |
||
68 | 542 |
!TestResult methodsFor:'running'! |
0 | 543 |
|
303 | 544 |
performCase:aTestCase |
545 |
"Actually performs the case. The TestCase>>runCase itself calls |
|
300
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
546 |
a setUp/tearDown methods. The possible error/failure is handled |
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
547 |
in TestResult>>runCase:. This method is meant to be overriden by |
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
548 |
custom TestResult subclasses." |
643 | 549 |
|
550 |
[ |
|
551 |
aTestCase runCase. |
|
730 | 552 |
] sunitOn:(self class skipped) do: [:ex | |
643 | 553 |
ex sunitAnnounce: aTestCase toResult: self. |
554 |
ex return. |
|
730 | 555 |
]. |
300
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
556 |
|
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
557 |
"Modified: / 02-08-2011 / 18:10:09 / cg" |
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
558 |
"Created: / 03-08-2011 / 14:02:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
730 | 559 |
"Modified: / 23-03-2019 / 10:33:08 / Claus Gittinger" |
300
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
560 |
! |
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
561 |
|
303 | 562 |
runCase:aTestCase |
316 | 563 |
"run a testcase, catching exceptions" |
564 |
||
429 | 565 |
self runCase:aTestCase debugged:false |
566 |
||
567 |
"Modified: / 16-08-2011 / 17:35:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
568 |
"Modified: / 21-08-2011 / 17:48:28 / cg" |
|
569 |
! |
|
570 |
||
571 |
runCase:aTestCase debugged:debugged |
|
572 |
"run a testcase, debugging exceptions" |
|
573 |
||
438 | 574 |
|
575 |
[ |
|
576 |
[ |
|
577 |
outcome := self createOutcome. |
|
578 |
outcome testCase: aTestCase. |
|
579 |
self rememberStartTime. |
|
580 |
self performCase:aTestCase. |
|
581 |
self rememberEndTime. |
|
730 | 582 |
(outcome result == TestResult stateSkip) ifFalse:[ |
583 |
self addPass:aTestCase. |
|
584 |
]. |
|
738 | 585 |
lastOutcome := outcome. |
438 | 586 |
outcome := nil. |
587 |
] sunitOn:self exceptions do: [:ex | |
|
588 |
self rememberEndTime. |
|
589 |
self rememberException: ex. |
|
572
7a3643c916c2
use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
590 |
(AbortSignal accepts: ex creator) ifTrue:[ex reject]. |
7a3643c916c2
use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
591 |
(TerminateProcessRequest accepts: ex creator) ifTrue:[ex reject]. |
603 | 592 |
debugged ifFalse:[ |
593 |
ex sunitAnnounce:aTestCase toResult:self. |
|
594 |
"/ not reached, because sunitAnnouce returns from ex!! |
|
595 |
]. |
|
644 | 596 |
(TestSkipped accepts: ex creator) ifFalse:[ |
597 |
self addFailure: aTestCase detail: ex. |
|
598 |
]. |
|
603 | 599 |
self breakPoint:#cg. |
600 |
ex reject. |
|
438 | 601 |
]. |
602 |
] sunitOn: self exceptions do:[:ex| |
|
644 | 603 |
(TestSkipped accepts: ex creator) ifTrue:[ex return]. |
572
7a3643c916c2
use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
604 |
(AbortSignal accepts: ex creator) ifTrue:[ex reject]. |
7a3643c916c2
use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
605 |
(TerminateProcessRequest accepts: ex creator) ifTrue:[ex reject]. |
596 | 606 |
"/ the stuff below is rubbish - it clears out the info as collected above!! |
607 |
"/ self remove: aTestCase. |
|
525 | 608 |
debugged ifTrue:[ ex reject ]. |
438 | 609 |
] |
292 | 610 |
|
429 | 611 |
"Created: / 21-08-2011 / 17:48:19 / cg" |
446 | 612 |
"Modified: / 04-06-2012 / 18:50:15 / cg" |
532
fa66c637614e
Removed halt in TestResult>>#runCase:debugged: - please do not commit debugging halts!
vrany
parents:
525
diff
changeset
|
613 |
"Modified: / 14-01-2013 / 13:28:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
738 | 614 |
"Modified: / 28-03-2019 / 11:24:26 / Claus Gittinger" |
0 | 615 |
! ! |
616 |
||
68 | 617 |
!TestResult methodsFor:'testing'! |
0 | 618 |
|
53 | 619 |
hasErrors |
620 |
||
671 | 621 |
^self errors notEmptyOrNil |
53 | 622 |
! |
623 |
||
624 |
hasFailures |
|
625 |
||
671 | 626 |
^self failures notEmptyOrNil |
53 | 627 |
! |
628 |
||
446 | 629 |
hasFailuresOrErrors |
630 |
^ self hasFailures or:[self hasErrors] |
|
631 |
||
632 |
"Created: / 04-06-2012 / 19:06:52 / cg" |
|
633 |
! |
|
634 |
||
0 | 635 |
hasPassed |
104 | 636 |
|
637 |
^self hasErrors not and: [self hasFailures not] |
|
53 | 638 |
! |
639 |
||
671 | 640 |
hasSkipped |
641 |
||
642 |
^self skipped notEmptyOrNil |
|
643 |
! |
|
644 |
||
53 | 645 |
isError: aTestCase |
646 |
||
104 | 647 |
^self errors includes: aTestCase |
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
648 |
! |
0 | 649 |
|
650 |
isFailure: aTestCase |
|
104 | 651 |
^self failures includes: aTestCase |
53 | 652 |
! |
653 |
||
654 |
isPassed: aTestCase |
|
655 |
||
104 | 656 |
^self passed includes: aTestCase |
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
657 |
! ! |
0 | 658 |
|
14 | 659 |
!TestResult class methodsFor:'documentation'! |
660 |
||
661 |
version |
|
629 | 662 |
^ '$Header$' |
297
87eb8f911bcf
changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents:
292
diff
changeset
|
663 |
! |
87eb8f911bcf
changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents:
292
diff
changeset
|
664 |
|
87eb8f911bcf
changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents:
292
diff
changeset
|
665 |
version_CVS |
629 | 666 |
^ '$Header$' |
222 | 667 |
! |
668 |
||
669 |
version_SVN |
|
629 | 670 |
^ '$Id$' |
14 | 671 |
! ! |
549 | 672 |