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