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