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