author | Claus Gittinger <cg@exept.de> |
Sun, 17 Nov 2019 15:31:29 +0100 | |
changeset 763 | 5e18fecc685b |
parent 760 | a40d1124cee8 |
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. |
760 | 398 |
self errorOutcomes add:outcome. |
399 |
^ outcome |
|
300
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
400 |
|
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
401 |
"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
|
402 |
"Modified: / 06-08-2011 / 09:46:41 / cg" |
418 | 403 |
"Modified: / 20-08-2011 / 12:46:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
676 | 404 |
"Modified (comment): / 22-05-2017 / 18:27:02 / mawalch" |
222 | 405 |
! |
406 |
||
676 | 407 |
addFailure:testcase detail:detail |
408 |
"Called when a test fails. testCase is the failed |
|
347 | 409 |
testcase, detail is platform specific object describing |
676 | 410 |
the failure. Actually, on all platforms except GemStone, |
347 | 411 |
detail is an instance of an exception that caused the failure" |
412 |
"JV2011-08-03: TODO: Validate the comment above with GS, |
|
413 |
possibly change name to 'exception'" |
|
418 | 414 |
|
347 | 415 |
"Special handling here, because failures can be resumable" |
676 | 416 |
self failureOutcomes do:[:outcome | |
347 | 417 |
outcome testCase = testcase ifTrue:[ |
418 |
^ self |
|
419 |
]. |
|
420 |
]. |
|
525 | 421 |
outcome result: (TestResult stateFail). |
418 | 422 |
outcome remember. |
760 | 423 |
self failureOutcomes add:outcome. |
424 |
^ outcome |
|
300
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
425 |
|
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
426 |
"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
|
427 |
"Modified: / 06-08-2011 / 09:55:17 / cg" |
418 | 428 |
"Modified: / 20-08-2011 / 12:46:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
676 | 429 |
"Modified (comment): / 22-05-2017 / 18:25:30 / mawalch" |
318
96ce5904bba6
added: #rememberException:detail:
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
430 |
! |
96ce5904bba6
added: #rememberException:detail:
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
431 |
|
418 | 432 |
addPass:testCase |
433 |
||
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
434 |
outcome result: (TestResult statePass). |
418 | 435 |
outcome remember. |
760 | 436 |
self passedOutcomes add: outcome. |
437 |
^ outcome |
|
325
76240d956e7d
changed: #rememberExceptionIn:detail:
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
438 |
|
418 | 439 |
"Modified: / 20-08-2011 / 12:44:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
438 | 440 |
! |
441 |
||
753 | 442 |
addSkipped:testCase |
443 |
<resource: #obsolete> |
|
444 |
||
445 |
self addSkipped:testCase detail:nil |
|
446 |
||
447 |
"Modified: / 08-06-2019 / 13:55:15 / Claus Gittinger" |
|
448 |
! |
|
449 |
||
450 |
addSkipped:testCase detail:detail |
|
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
451 |
|
525 | 452 |
outcome result: (TestResult stateSkip). |
759 | 453 |
outcome exceptionDetail:('skipped because: ',detail asString). |
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
454 |
outcome remember. |
760 | 455 |
self skippedOutcomes add: outcome. |
456 |
^ outcome |
|
753 | 457 |
|
458 |
"Created: / 08-06-2019 / 13:49:15 / Claus Gittinger" |
|
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
459 |
! |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
460 |
|
438 | 461 |
remove: aTestCase |
462 |
"Removes an outcome for given testcase, if any. |
|
463 |
Use with care." |
|
464 |
||
465 |
| remover | |
|
466 |
||
467 |
remover := [:outcomes| |
|
468 |
| o | |
|
469 |
||
470 |
outcomes notNil ifTrue:[ |
|
471 |
o := outcomes detect:[:each|each testCase == aTestCase] ifNone: [nil]. |
|
472 |
o notNil ifTrue:[outcomes remove: o. ^self]. |
|
473 |
]. |
|
474 |
]. |
|
475 |
||
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
476 |
remover value: skipped. |
438 | 477 |
remover value: errors. |
478 |
remover value: failures. |
|
479 |
remover value: passed. |
|
480 |
||
481 |
"Created: / 16-01-2012 / 20:36:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
222 | 482 |
! ! |
483 |
||
484 |
!TestResult methodsFor:'deprecated'! |
|
485 |
||
486 |
correctCount |
|
487 |
"deprecated - use #passedCount" |
|
488 |
||
489 |
^self passedCount |
|
490 |
! ! |
|
491 |
||
492 |
!TestResult methodsFor:'initialize-release'! |
|
0 | 493 |
|
494 |
initialize |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
495 |
! ! |
0 | 496 |
|
347 | 497 |
!TestResult methodsFor:'outcome'! |
498 |
||
499 |
createOutcome |
|
500 |
||
501 |
^TestCaseOutcome new. |
|
0 | 502 |
|
347 | 503 |
"Created: / 16-08-2011 / 17:14:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
504 |
! |
|
297
87eb8f911bcf
changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents:
292
diff
changeset
|
505 |
|
738 | 506 |
lastOutcome |
507 |
"the outcome of the last executed case |
|
508 |
(only valid in the run...after:[] block)" |
|
509 |
||
510 |
^ lastOutcome. |
|
511 |
||
512 |
"Created: / 28-03-2019 / 11:21:21 / Claus Gittinger" |
|
513 |
! |
|
514 |
||
347 | 515 |
rememberEndTime |
743 | 516 |
"remembers the endTime of the current test" |
347 | 517 |
|
743 | 518 |
endTime := Timestamp now |
292 | 519 |
|
347 | 520 |
"Created: / 16-08-2011 / 17:31:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
743 | 521 |
"Modified (comment): / 28-03-2019 / 13:44:56 / Claus Gittinger" |
347 | 522 |
! |
523 |
||
524 |
rememberException:detail |
|
525 |
||
526 |
"Created: / 16-08-2011 / 17:35:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
527 |
! |
|
292 | 528 |
|
347 | 529 |
rememberStartTime |
478 | 530 |
"remembers the startTime of the current test (in outcome)" |
347 | 531 |
|
532 |
^nil |
|
292 | 533 |
|
347 | 534 |
"Created: / 16-08-2011 / 17:31:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
535 |
! ! |
|
536 |
||
537 |
!TestResult methodsFor:'printing'! |
|
292 | 538 |
|
0 | 539 |
printOn: aStream |
104 | 540 |
|
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
541 |
aStream |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
542 |
nextPutAll: self runCount printString; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
543 |
nextPutAll: ' run, '; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
544 |
nextPutAll: self passedCount printString; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
545 |
nextPutAll: ' passed, '; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
546 |
nextPutAll: self skippedCount printString; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
547 |
nextPutAll: ' skipped, '; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
548 |
nextPutAll: self failureCount printString; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
549 |
nextPutAll: ' failed, '; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
550 |
nextPutAll: self errorCount printString; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
551 |
nextPutAll: ' error'. |
104 | 552 |
|
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
553 |
self errorCount ~= 1 |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
554 |
ifTrue: [aStream nextPut: $s] |
0 | 555 |
! ! |
556 |
||
68 | 557 |
!TestResult methodsFor:'running'! |
0 | 558 |
|
303 | 559 |
performCase:aTestCase |
560 |
"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
|
561 |
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
|
562 |
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
|
563 |
custom TestResult subclasses." |
643 | 564 |
|
565 |
[ |
|
566 |
aTestCase runCase. |
|
730 | 567 |
] sunitOn:(self class skipped) do: [:ex | |
643 | 568 |
ex sunitAnnounce: aTestCase toResult: self. |
569 |
ex return. |
|
730 | 570 |
]. |
300
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
571 |
|
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
572 |
"Modified: / 02-08-2011 / 18:10:09 / cg" |
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
573 |
"Created: / 03-08-2011 / 14:02:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
730 | 574 |
"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
|
575 |
! |
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
576 |
|
303 | 577 |
runCase:aTestCase |
316 | 578 |
"run a testcase, catching exceptions" |
579 |
||
429 | 580 |
self runCase:aTestCase debugged:false |
581 |
||
582 |
"Modified: / 16-08-2011 / 17:35:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
583 |
"Modified: / 21-08-2011 / 17:48:28 / cg" |
|
584 |
! |
|
585 |
||
586 |
runCase:aTestCase debugged:debugged |
|
587 |
"run a testcase, debugging exceptions" |
|
588 |
||
438 | 589 |
|
590 |
[ |
|
591 |
[ |
|
592 |
outcome := self createOutcome. |
|
593 |
outcome testCase: aTestCase. |
|
594 |
self rememberStartTime. |
|
595 |
self performCase:aTestCase. |
|
596 |
self rememberEndTime. |
|
730 | 597 |
(outcome result == TestResult stateSkip) ifFalse:[ |
598 |
self addPass:aTestCase. |
|
599 |
]. |
|
738 | 600 |
lastOutcome := outcome. |
438 | 601 |
outcome := nil. |
602 |
] sunitOn:self exceptions do: [:ex | |
|
603 |
self rememberEndTime. |
|
604 |
self rememberException: ex. |
|
572
7a3643c916c2
use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
605 |
(AbortSignal accepts: ex creator) ifTrue:[ex reject]. |
7a3643c916c2
use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
606 |
(TerminateProcessRequest accepts: ex creator) ifTrue:[ex reject]. |
603 | 607 |
debugged ifFalse:[ |
608 |
ex sunitAnnounce:aTestCase toResult:self. |
|
609 |
"/ not reached, because sunitAnnouce returns from ex!! |
|
610 |
]. |
|
644 | 611 |
(TestSkipped accepts: ex creator) ifFalse:[ |
612 |
self addFailure: aTestCase detail: ex. |
|
613 |
]. |
|
603 | 614 |
self breakPoint:#cg. |
615 |
ex reject. |
|
438 | 616 |
]. |
617 |
] sunitOn: self exceptions do:[:ex| |
|
644 | 618 |
(TestSkipped accepts: ex creator) ifTrue:[ex return]. |
572
7a3643c916c2
use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
619 |
(AbortSignal accepts: ex creator) ifTrue:[ex reject]. |
7a3643c916c2
use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
620 |
(TerminateProcessRequest accepts: ex creator) ifTrue:[ex reject]. |
596 | 621 |
"/ the stuff below is rubbish - it clears out the info as collected above!! |
622 |
"/ self remove: aTestCase. |
|
525 | 623 |
debugged ifTrue:[ ex reject ]. |
438 | 624 |
] |
292 | 625 |
|
429 | 626 |
"Created: / 21-08-2011 / 17:48:19 / cg" |
446 | 627 |
"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
|
628 |
"Modified: / 14-01-2013 / 13:28:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
738 | 629 |
"Modified: / 28-03-2019 / 11:24:26 / Claus Gittinger" |
0 | 630 |
! ! |
631 |
||
68 | 632 |
!TestResult methodsFor:'testing'! |
0 | 633 |
|
53 | 634 |
hasErrors |
635 |
||
671 | 636 |
^self errors notEmptyOrNil |
53 | 637 |
! |
638 |
||
639 |
hasFailures |
|
640 |
||
671 | 641 |
^self failures notEmptyOrNil |
53 | 642 |
! |
643 |
||
446 | 644 |
hasFailuresOrErrors |
645 |
^ self hasFailures or:[self hasErrors] |
|
646 |
||
647 |
"Created: / 04-06-2012 / 19:06:52 / cg" |
|
648 |
! |
|
649 |
||
0 | 650 |
hasPassed |
104 | 651 |
|
652 |
^self hasErrors not and: [self hasFailures not] |
|
53 | 653 |
! |
654 |
||
671 | 655 |
hasSkipped |
656 |
||
657 |
^self skipped notEmptyOrNil |
|
658 |
! |
|
659 |
||
53 | 660 |
isError: aTestCase |
661 |
||
104 | 662 |
^self errors includes: aTestCase |
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
663 |
! |
0 | 664 |
|
665 |
isFailure: aTestCase |
|
104 | 666 |
^self failures includes: aTestCase |
53 | 667 |
! |
668 |
||
669 |
isPassed: aTestCase |
|
670 |
||
104 | 671 |
^self passed includes: aTestCase |
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
672 |
! ! |
0 | 673 |
|
14 | 674 |
!TestResult class methodsFor:'documentation'! |
675 |
||
676 |
version |
|
629 | 677 |
^ '$Header$' |
297
87eb8f911bcf
changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents:
292
diff
changeset
|
678 |
! |
87eb8f911bcf
changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents:
292
diff
changeset
|
679 |
|
87eb8f911bcf
changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents:
292
diff
changeset
|
680 |
version_CVS |
629 | 681 |
^ '$Header$' |
222 | 682 |
! |
683 |
||
684 |
version_SVN |
|
629 | 685 |
^ '$Id$' |
14 | 686 |
! ! |
549 | 687 |