author | Claus Gittinger <cg@exept.de> |
Thu, 26 Feb 2015 05:01:33 +0100 | |
changeset 607 | 8d830a63bfc0 |
parent 603 | ccbf7219ef3d |
child 629 | 05b7684be923 |
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 |
|
462 | 28 |
self sunitName == #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 |
|
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
168 |
^self class failure , self class error |
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 |
|
104 | 263 |
^self passedCount + self failureCount + self errorCount |
53 | 264 |
! |
265 |
||
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
266 |
skipped |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
267 |
skipped isNil ifTrue: [ |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
268 |
"/ cg: exposed and added to (see TestRunnerEmbedded>>debug) |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
269 |
skipped := OrderedCollection new. |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
270 |
^ skipped. |
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 |
^skipped collect:[:each|each testCase] |
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 |
|
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
275 |
skippedCount |
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 |
^self skippedOutcomes size |
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 |
|
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
280 |
skippedOutcomes |
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 |
skipped isNil ifTrue: [skipped := OrderedCollection new]. |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
283 |
^skipped |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
284 |
! |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
285 |
|
347 | 286 |
testOutcomes |
287 |
||
288 |
^(OrderedCollection new: self runCount) |
|
289 |
addAll: self passedOutcomes; |
|
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
290 |
addAll: self skippedOutcomes; |
347 | 291 |
addAll: self errorOutcomes; |
292 |
addAll: self failureOutcomes; |
|
293 |
yourself |
|
294 |
||
295 |
"Created: / 16-08-2011 / 16:42:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
296 |
! |
|
297 |
||
53 | 298 |
tests |
104 | 299 |
|
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
300 |
^(OrderedCollection new: self runCount) |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
301 |
addAll: self passed; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
302 |
addAll: self skipped; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
303 |
addAll: self errors; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
304 |
addAll: self failures; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
305 |
yourself |
222 | 306 |
! |
307 |
||
308 |
timestamp |
|
309 |
^ timestamp |
|
270 | 310 |
! |
311 |
||
478 | 312 |
timestamp:aTimestamp |
313 |
timestamp := aTimestamp. |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
314 |
! ! |
0 | 315 |
|
438 | 316 |
!TestResult methodsFor:'adding / removing'! |
222 | 317 |
|
347 | 318 |
addError:testcase detail:detail |
319 |
"Called when a test outcome is error. testCase |
|
320 |
is the errorneous testcase, detail is platform |
|
321 |
specific object describing the error. Actually, |
|
322 |
on all platforms exept GemStone, detail is an instance |
|
323 |
of an exception that caused the error" |
|
324 |
"JV2011-08-03: TODO: Validate the comment above with GS, |
|
325 |
possibly change name to 'exception'" |
|
300
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
326 |
|
418 | 327 |
|
525 | 328 |
outcome result: (TestResult stateError). |
418 | 329 |
outcome remember. |
347 | 330 |
^ self errorOutcomes add:outcome. |
300
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
331 |
|
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
332 |
"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
|
333 |
"Modified: / 06-08-2011 / 09:46:41 / cg" |
418 | 334 |
"Modified: / 20-08-2011 / 12:46:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
222 | 335 |
! |
336 |
||
347 | 337 |
addFailure:testcase detail:detail |
338 |
"Called when a test fails. testCase is the failed |
|
339 |
testcase, detail is platform specific object describing |
|
340 |
the failure. Actually, on all platforms exept GemStone, |
|
341 |
detail is an instance of an exception that caused the failure" |
|
342 |
"JV2011-08-03: TODO: Validate the comment above with GS, |
|
343 |
possibly change name to 'exception'" |
|
418 | 344 |
|
347 | 345 |
"Special handling here, because failures can be resumable" |
346 |
self failureOutcomes do:[:outcome | |
|
347 |
outcome testCase = testcase ifTrue:[ |
|
348 |
^ self |
|
349 |
]. |
|
350 |
]. |
|
525 | 351 |
outcome result: (TestResult stateFail). |
418 | 352 |
outcome remember. |
347 | 353 |
^ self failureOutcomes add: outcome |
300
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
354 |
|
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
355 |
"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
|
356 |
"Modified: / 06-08-2011 / 09:55:17 / cg" |
418 | 357 |
"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
|
358 |
! |
96ce5904bba6
added: #rememberException:detail:
Claus Gittinger <cg@exept.de>
parents:
316
diff
changeset
|
359 |
|
418 | 360 |
addPass:testCase |
361 |
||
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
362 |
outcome result: (TestResult statePass). |
418 | 363 |
outcome remember. |
347 | 364 |
^ self passedOutcomes add: outcome |
325
76240d956e7d
changed: #rememberExceptionIn:detail:
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
365 |
|
418 | 366 |
"Modified: / 20-08-2011 / 12:44:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
438 | 367 |
! |
368 |
||
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
369 |
addSkipped:testCase |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
370 |
|
525 | 371 |
outcome result: (TestResult stateSkip). |
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
372 |
outcome remember. |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
373 |
^ self skippedOutcomes add: outcome |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
374 |
! |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
375 |
|
438 | 376 |
remove: aTestCase |
377 |
"Removes an outcome for given testcase, if any. |
|
378 |
Use with care." |
|
379 |
||
380 |
| remover | |
|
381 |
||
382 |
remover := [:outcomes| |
|
383 |
| o | |
|
384 |
||
385 |
outcomes notNil ifTrue:[ |
|
386 |
o := outcomes detect:[:each|each testCase == aTestCase] ifNone: [nil]. |
|
387 |
o notNil ifTrue:[outcomes remove: o. ^self]. |
|
388 |
]. |
|
389 |
]. |
|
390 |
||
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
391 |
remover value: skipped. |
438 | 392 |
remover value: errors. |
393 |
remover value: failures. |
|
394 |
remover value: passed. |
|
395 |
||
396 |
"Created: / 16-01-2012 / 20:36:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
222 | 397 |
! ! |
398 |
||
399 |
!TestResult methodsFor:'deprecated'! |
|
400 |
||
401 |
correctCount |
|
402 |
"deprecated - use #passedCount" |
|
403 |
||
404 |
^self passedCount |
|
405 |
! ! |
|
406 |
||
407 |
!TestResult methodsFor:'initialize-release'! |
|
0 | 408 |
|
409 |
initialize |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
410 |
! ! |
0 | 411 |
|
347 | 412 |
!TestResult methodsFor:'outcome'! |
413 |
||
414 |
createOutcome |
|
415 |
||
416 |
^TestCaseOutcome new. |
|
0 | 417 |
|
347 | 418 |
"Created: / 16-08-2011 / 17:14:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
419 |
! |
|
297
87eb8f911bcf
changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents:
292
diff
changeset
|
420 |
|
347 | 421 |
rememberEndTime |
478 | 422 |
"remembers the endTime of the current test (in outcome)" |
347 | 423 |
|
424 |
^nil |
|
292 | 425 |
|
347 | 426 |
"Created: / 16-08-2011 / 17:31:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
427 |
! |
|
428 |
||
429 |
rememberException:detail |
|
430 |
||
431 |
"Created: / 16-08-2011 / 17:35:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
432 |
! |
|
292 | 433 |
|
347 | 434 |
rememberStartTime |
478 | 435 |
"remembers the startTime of the current test (in outcome)" |
347 | 436 |
|
437 |
^nil |
|
292 | 438 |
|
347 | 439 |
"Created: / 16-08-2011 / 17:31:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
440 |
! ! |
|
441 |
||
442 |
!TestResult methodsFor:'printing'! |
|
292 | 443 |
|
0 | 444 |
printOn: aStream |
104 | 445 |
|
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
446 |
aStream |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
447 |
nextPutAll: self runCount printString; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
448 |
nextPutAll: ' run, '; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
449 |
nextPutAll: self passedCount printString; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
450 |
nextPutAll: ' passed, '; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
451 |
nextPutAll: self skippedCount printString; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
452 |
nextPutAll: ' skipped, '; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
453 |
nextPutAll: self failureCount printString; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
454 |
nextPutAll: ' failed, '; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
455 |
nextPutAll: self errorCount printString; |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
456 |
nextPutAll: ' error'. |
104 | 457 |
|
487
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
458 |
self errorCount ~= 1 |
52803f8a7029
preparations for skipping tests;
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
459 |
ifTrue: [aStream nextPut: $s] |
0 | 460 |
! ! |
461 |
||
68 | 462 |
!TestResult methodsFor:'running'! |
0 | 463 |
|
303 | 464 |
performCase:aTestCase |
465 |
"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
|
466 |
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
|
467 |
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
|
468 |
custom TestResult subclasses." |
303 | 469 |
|
300
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
470 |
aTestCase runCase. |
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
471 |
|
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
472 |
"Modified: / 02-08-2011 / 18:10:09 / cg" |
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
473 |
"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
|
474 |
! |
570aed392231
TestResult refactoring - now it allow for more fine-grained customization
vrany
parents:
297
diff
changeset
|
475 |
|
303 | 476 |
runCase:aTestCase |
316 | 477 |
"run a testcase, catching exceptions" |
478 |
||
429 | 479 |
self runCase:aTestCase debugged:false |
480 |
||
481 |
"Modified: / 16-08-2011 / 17:35:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
482 |
"Modified: / 21-08-2011 / 17:48:28 / cg" |
|
483 |
! |
|
484 |
||
485 |
runCase:aTestCase debugged:debugged |
|
486 |
"run a testcase, debugging exceptions" |
|
487 |
||
438 | 488 |
|
489 |
[ |
|
490 |
[ |
|
491 |
outcome := self createOutcome. |
|
492 |
outcome testCase: aTestCase. |
|
493 |
self rememberStartTime. |
|
494 |
self performCase:aTestCase. |
|
495 |
self rememberEndTime. |
|
496 |
self addPass:aTestCase. |
|
497 |
outcome := nil. |
|
498 |
] sunitOn:self exceptions do: [:ex | |
|
499 |
self rememberEndTime. |
|
500 |
self rememberException: ex. |
|
572
7a3643c916c2
use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
501 |
(AbortSignal accepts: ex creator) ifTrue:[ex reject]. |
7a3643c916c2
use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
502 |
(TerminateProcessRequest accepts: ex creator) ifTrue:[ex reject]. |
603 | 503 |
debugged ifFalse:[ |
504 |
ex sunitAnnounce:aTestCase toResult:self. |
|
505 |
"/ not reached, because sunitAnnouce returns from ex!! |
|
506 |
]. |
|
507 |
self addFailure: aTestCase detail: ex. |
|
508 |
self breakPoint:#cg. |
|
509 |
ex reject. |
|
438 | 510 |
]. |
511 |
] sunitOn: self exceptions do:[:ex| |
|
572
7a3643c916c2
use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
512 |
(AbortSignal accepts: ex creator) ifTrue:[ex reject]. |
7a3643c916c2
use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents:
549
diff
changeset
|
513 |
(TerminateProcessRequest accepts: ex creator) ifTrue:[ex reject]. |
596 | 514 |
"/ the stuff below is rubbish - it clears out the info as collected above!! |
515 |
"/ self remove: aTestCase. |
|
525 | 516 |
debugged ifTrue:[ ex reject ]. |
438 | 517 |
] |
292 | 518 |
|
429 | 519 |
"Created: / 21-08-2011 / 17:48:19 / cg" |
446 | 520 |
"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
|
521 |
"Modified: / 14-01-2013 / 13:28:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 522 |
! ! |
523 |
||
68 | 524 |
!TestResult methodsFor:'testing'! |
0 | 525 |
|
53 | 526 |
hasErrors |
527 |
||
104 | 528 |
^self errors size > 0 |
53 | 529 |
! |
530 |
||
531 |
hasFailures |
|
532 |
||
104 | 533 |
^self failures size > 0 |
53 | 534 |
! |
535 |
||
446 | 536 |
hasFailuresOrErrors |
537 |
^ self hasFailures or:[self hasErrors] |
|
538 |
||
539 |
"Created: / 04-06-2012 / 19:06:52 / cg" |
|
540 |
! |
|
541 |
||
0 | 542 |
hasPassed |
104 | 543 |
|
544 |
^self hasErrors not and: [self hasFailures not] |
|
53 | 545 |
! |
546 |
||
547 |
isError: aTestCase |
|
548 |
||
104 | 549 |
^self errors includes: aTestCase |
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
550 |
! |
0 | 551 |
|
552 |
isFailure: aTestCase |
|
104 | 553 |
^self failures includes: aTestCase |
53 | 554 |
! |
555 |
||
556 |
isPassed: aTestCase |
|
557 |
||
104 | 558 |
^self passed includes: aTestCase |
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
559 |
! ! |
0 | 560 |
|
14 | 561 |
!TestResult class methodsFor:'documentation'! |
562 |
||
563 |
version |
|
603 | 564 |
^ '$Header: /cvs/stx/stx/goodies/sunit/TestResult.st,v 1.57 2015-02-06 08:53:20 cg Exp $' |
297
87eb8f911bcf
changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents:
292
diff
changeset
|
565 |
! |
87eb8f911bcf
changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents:
292
diff
changeset
|
566 |
|
87eb8f911bcf
changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents:
292
diff
changeset
|
567 |
version_CVS |
603 | 568 |
^ '$Header: /cvs/stx/stx/goodies/sunit/TestResult.st,v 1.57 2015-02-06 08:53:20 cg Exp $' |
222 | 569 |
! |
570 |
||
571 |
version_SVN |
|
603 | 572 |
^ '$Id: TestResult.st,v 1.57 2015-02-06 08:53:20 cg Exp $' |
14 | 573 |
! ! |
549 | 574 |