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