author | Jan Vrany <jan.vrany@labware.com> |
Fri, 07 Oct 2022 12:27:15 +0100 | |
branch | jv |
changeset 773 | 5e936bce7857 |
parent 771 | d1c18e4f543c |
permissions | -rw-r--r-- |
771
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
1 |
" |
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
2 |
COPYRIGHT (c) 2022 LabWare |
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
3 |
" |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
4 |
"{ Package: 'stx:goodies/sunit' }" |
0 | 5 |
|
599 | 6 |
"{ NameSpace: Smalltalk }" |
7 |
||
222 | 8 |
TestAsserter subclass:#TestCase |
377 | 9 |
instanceVariableNames:'testSelector' |
10 |
classVariableNames:'' |
|
11 |
poolDictionaries:'' |
|
12 |
category:'SUnit-Base' |
|
0 | 13 |
! |
14 |
||
382 | 15 |
TestCase class instanceVariableNames:'lastOutcomes' |
81 | 16 |
|
17 |
" |
|
18 |
No other class instance variables are inherited by this class. |
|
19 |
" |
|
20 |
! |
|
21 |
||
771
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
22 |
!TestCase class methodsFor:'documentation'! |
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
23 |
|
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
24 |
copyright |
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
25 |
" |
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
26 |
COPYRIGHT (c) 2022 LabWare |
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
27 |
|
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
28 |
" |
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
29 |
! ! |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
30 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
31 |
!TestCase class methodsFor:'initialization'! |
12 | 32 |
|
435 | 33 |
flushAll |
34 |
||
35 |
"Flush all remembered outcomes in all testcases" |
|
36 |
||
37 |
self withAllSubclassesDo:[:cls| |
|
594 | 38 |
cls flushRememberedOutcomes |
435 | 39 |
] |
40 |
||
41 |
"Created: / 17-11-2011 / 19:18:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
42 |
! |
|
43 |
||
44 |
flushRememberedOutcomes |
|
45 |
||
46 |
"Flushes all remembered outcomes for the receiver" |
|
47 |
||
48 |
| outcomes | |
|
49 |
||
50 |
lastOutcomes isNil ifTrue:[^self]. |
|
594 | 51 |
outcomes := lastOutcomes. |
435 | 52 |
lastOutcomes := nil. |
53 |
outcomes do:[:outcome| |
|
594 | 54 |
self lastTestRunResultChanged: outcome selector. |
435 | 55 |
] |
56 |
||
57 |
"Created: / 17-11-2011 / 19:17:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
58 |
! |
|
59 |
||
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
60 |
initialize |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
61 |
ResumableTestFailure autoload |
138 | 62 |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
63 |
" |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
64 |
self initialize |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
65 |
" |
326 | 66 |
! |
67 |
||
68 |
postAutoload |
|
433 | 69 |
|pd| |
70 |
||
71 |
(pd := self projectDefinitionClass) notNil ifTrue:[ |
|
594 | 72 |
pd loadExtensions |
433 | 73 |
] |
74 |
||
75 |
"Modified: / 02-11-2011 / 15:44:58 / sr" |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
76 |
! ! |
138 | 77 |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
78 |
!TestCase class methodsFor:'instance creation'! |
2 | 79 |
|
288 | 80 |
asTestCase |
81 |
^ self |
|
82 |
||
83 |
"Created: / 02-08-2011 / 09:12:13 / cg" |
|
84 |
! |
|
85 |
||
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
86 |
debug: aSymbol |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
87 |
|
594 | 88 |
^(self selector: aSymbol) debug |
138 | 89 |
! |
2 | 90 |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
91 |
run: aSymbol |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
92 |
|
594 | 93 |
^(self selector: aSymbol) run |
138 | 94 |
! |
95 |
||
0 | 96 |
selector: aSymbol |
103 | 97 |
|
594 | 98 |
^self new setTestSelector: aSymbol |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
99 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
100 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
101 |
suite |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
102 |
|
594 | 103 |
^self buildSuite |
0 | 104 |
! ! |
105 |
||
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
106 |
!TestCase class methodsFor:'accessing'! |
66 | 107 |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
108 |
allTestSelectors |
328
66cae160c956
added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
109 |
| answer pivotClass lookupRoot | |
66cae160c956
added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
110 |
|
66cae160c956
added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
111 |
answer := Set withAll: self testSelectors. |
66cae160c956
added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
112 |
self shouldInheritSelectors ifTrue:[ |
669 | 113 |
pivotClass := self superclass. |
114 |
lookupRoot := self lookupHierarchyRoot. |
|
115 |
[pivotClass == lookupRoot] whileFalse:[ |
|
116 |
answer addAll: pivotClass testSelectors. |
|
117 |
pivotClass := pivotClass superclass. |
|
118 |
] |
|
328
66cae160c956
added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
119 |
]. |
669 | 120 |
answer := answer asOrderedCollection. |
121 |
answer sort. |
|
122 |
^ answer |
|
420 | 123 |
|
421 | 124 |
"Modified: / 21-08-2011 / 15:06:11 / cg" |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
125 |
! |
66 | 126 |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
127 |
forgetLastTestRunResult |
390 | 128 |
|
129 |
Smalltalk changed:#lastTestRunResult with:(Array with:self with:nil). |
|
130 |
self changed:#lastTestRunResult. |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
131 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
132 |
"Modified: / 06-08-2006 / 11:40:07 / cg" |
390 | 133 |
"Modified: / 20-08-2011 / 15:10:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
134 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
135 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
136 |
isTestSelector:aSelector |
771
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
137 |
^aSelector notNil and:['test*' sunitMatch: aSelector] |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
138 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
139 |
"Created: / 06-08-2006 / 11:46:17 / cg" |
222 | 140 |
"Modified: / 05-12-2009 / 18:50:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
290 | 141 |
"Modified: / 02-08-2011 / 17:46:51 / cg" |
771
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
142 |
"Modified: / 01-09-2022 / 21:51:43 / Jan Vrany <jan.vrany@labware.com>" |
222 | 143 |
! |
144 |
||
382 | 145 |
lastTestRunResultOrNil |
578 | 146 |
"Returns a state (TestResult stateXXX), depending |
147 |
on the state of the tests: |
|
594 | 148 |
statePass if all tests passed, |
149 |
stateError if any error, |
|
150 |
stateFail if any fail, |
|
151 |
or nil if never run |
|
578 | 152 |
" |
222 | 153 |
|
578 | 154 |
|anyFail| |
155 |
||
382 | 156 |
lastOutcomes isNil ifTrue:[^nil]. |
157 |
lastOutcomes size ~= self testSelectors size ifTrue:[^nil]. |
|
578 | 158 |
anyFail := false. |
159 |
||
382 | 160 |
lastOutcomes do:[:outcome| |
594 | 161 |
outcome result == (TestResult stateError) ifTrue:[ |
162 |
^ TestResult stateError |
|
163 |
]. |
|
164 |
outcome result == (TestResult stateFail) ifTrue:[ |
|
165 |
anyFail := true |
|
166 |
]. |
|
382 | 167 |
]. |
578 | 168 |
anyFail ifTrue:[ ^ TestResult stateFail ]. |
169 |
^ TestResult statePass |
|
222 | 170 |
|
382 | 171 |
"Modified: / 20-08-2011 / 14:59:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
172 |
! |
87
24e88e7f5d88
remember individual failed cases.
Claus Gittinger <cg@exept.de>
parents:
82
diff
changeset
|
173 |
|
222 | 174 |
lookupHierarchyRoot |
594 | 175 |
^TestCase |
222 | 176 |
! |
177 |
||
523 | 178 |
rememberOutcome: thisOutcome |
626 | 179 |
|thisTestCase someOtherOutcome someOtherTestCase |
180 |
thisTestCaseSelector thisTestCaseClassName| |
|
523 | 181 |
|
182 |
thisTestCase := thisOutcome testCase. |
|
626 | 183 |
thisTestCaseSelector := thisTestCase selector. |
184 |
thisTestCaseClassName := thisTestCase class name. |
|
185 |
||
382 | 186 |
lastOutcomes isNil ifTrue:[ |
626 | 187 |
lastOutcomes := OrderedCollection new. |
382 | 188 |
]. |
445 | 189 |
|
523 | 190 |
"Not a nice code, but portable (what: doWithIndex: is not portable?)" |
382 | 191 |
1 to: lastOutcomes size do:[:i| |
626 | 192 |
someOtherOutcome := lastOutcomes at: i. |
193 |
someOtherTestCase := someOtherOutcome testCase. |
|
194 |
"/ compare by classes name - in case it got redefined |
|
195 |
(someOtherTestCase selector == thisTestCaseSelector |
|
196 |
and: [someOtherTestCase class name = thisTestCaseClassName]) ifTrue:[ |
|
197 |
"remember; for the timestamp and other info" |
|
198 |
lastOutcomes at: i put: thisOutcome. |
|
199 |
someOtherOutcome result ~= thisOutcome result ifTrue:[ |
|
200 |
"but only send out change notification to browser if state has changed" |
|
201 |
self lastTestRunResultChanged: thisOutcome selector. |
|
202 |
]. |
|
203 |
^self. |
|
204 |
]. |
|
222 | 205 |
]. |
523 | 206 |
lastOutcomes add: thisOutcome. |
207 |
self lastTestRunResultChanged: thisOutcome selector. |
|
382 | 208 |
^self |
222 | 209 |
|
382 | 210 |
"Created: / 20-08-2011 / 12:43:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
445 | 211 |
"Modified: / 04-06-2012 / 16:19:07 / cg" |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
212 |
! |
81 | 213 |
|
382 | 214 |
rememberedOutcomeFor: selector |
222 | 215 |
|
382 | 216 |
lastOutcomes isNil ifTrue:[^nil]. |
594 | 217 |
^lastOutcomes |
218 |
detect: [:outcome| outcome testCase selector == selector] |
|
219 |
ifNone:[nil]. |
|
87
24e88e7f5d88
remember individual failed cases.
Claus Gittinger <cg@exept.de>
parents:
82
diff
changeset
|
220 |
|
382 | 221 |
"Created: / 20-08-2011 / 14:27:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
222 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
223 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
224 |
resources |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
225 |
|
594 | 226 |
^#() |
222 | 227 |
! |
228 |
||
229 |
shouldFork |
|
230 |
||
231 |
^false |
|
232 |
||
233 |
"Created: / 13-06-2011 / 16:46:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
103 | 234 |
! |
235 |
||
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
236 |
sunitVersion |
594 | 237 |
^'4.0' |
222 | 238 |
! |
239 |
||
391 | 240 |
testSelector:selector result: result |
523 | 241 |
"return true, if the last run of this test had the outcome result" |
382 | 242 |
|
243 |
lastOutcomes isNil ifTrue:[^false]. |
|
594 | 244 |
^ lastOutcomes |
607 | 245 |
contains:[:any| |
246 |
|tc| |
|
247 |
||
248 |
(tc := any testCase) class name = self name |
|
249 |
and:[tc selector == selector |
|
250 |
and:[any result == result]] |
|
251 |
] |
|
391 | 252 |
|
253 |
"Created: / 20-08-2011 / 16:15:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
445 | 254 |
"Modified: / 04-06-2012 / 16:12:17 / cg" |
391 | 255 |
! |
256 |
||
257 |
testSelectorError:selector |
|
523 | 258 |
"return true, if the last run of this test failed" |
391 | 259 |
|
523 | 260 |
^self testSelector: selector result: (TestResult stateError) |
222 | 261 |
|
262 |
"Created: / 15-03-2010 / 19:44:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
263 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
264 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
265 |
testSelectorFailed:selector |
523 | 266 |
"return true, if the last run of this test failed" |
222 | 267 |
|
523 | 268 |
^self testSelector: selector result: (TestResult stateFail) |
382 | 269 |
|
391 | 270 |
"Modified: / 20-08-2011 / 16:16:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
271 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
272 |
|
222 | 273 |
testSelectorPassed:selector |
523 | 274 |
"return true, if the last run of this test passed" |
382 | 275 |
|
523 | 276 |
^self testSelector: selector result: (TestResult statePass) |
277 |
||
278 |
"Created: / 15-03-2010 / 17:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
279 |
! |
|
280 |
||
281 |
testSelectorSkipped:selector |
|
282 |
"return true, if the last run of this test was skipped" |
|
283 |
||
284 |
^self testSelector: selector result: (TestResult stateSkip) |
|
211
3a40b828ce9a
comment/format in: #testSelectors
Claus Gittinger <cg@exept.de>
parents:
209
diff
changeset
|
285 |
|
222 | 286 |
"Created: / 15-03-2010 / 17:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
607 | 287 |
! |
288 |
||
289 |
testSelectorsWithLastOutcomes |
|
290 |
lastOutcomes isNil ifTrue:[^#()]. |
|
291 |
^lastOutcomes collect:[:outcome| outcome testCase selector] as:Set |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
292 |
! ! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
293 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
294 |
!TestCase class methodsFor:'building suites'! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
295 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
296 |
buildSuite |
594 | 297 |
| suite | |
298 |
self isAbstract |
|
299 |
ifTrue: |
|
300 |
[suite := self suiteClass named: self name asString. |
|
301 |
self allSubclasses |
|
302 |
do: [:each | each isAbstract ifFalse: [suite addTest: each buildSuiteFromSelectors]]. |
|
303 |
^ suite] |
|
304 |
ifFalse: [^ self buildSuiteFromSelectors] |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
305 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
306 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
307 |
buildSuiteFromMethods: testMethods |
68 | 308 |
|
594 | 309 |
^testMethods |
310 |
inject: (self suiteClass named: self name asString) |
|
311 |
into: [:suite :selector | |
|
312 |
suite |
|
313 |
addTest: (self selector: selector); |
|
314 |
yourself] |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
315 |
! |
138 | 316 |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
317 |
buildSuiteFromSelectors |
594 | 318 |
^self buildSuiteFromMethods: self allTestSelectors |
68 | 319 |
! |
320 |
||
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
321 |
suiteClass |
594 | 322 |
^TestSuite |
68 | 323 |
! ! |
324 |
||
203 | 325 |
!TestCase class methodsFor:'misc ui support'! |
326 |
||
327 |
iconInBrowserSymbol |
|
630
5b0539adf1c1
comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
328 |
"the browser will use this as index into the toolbariconlibrary" |
5b0539adf1c1
comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
329 |
|
203 | 330 |
<resource: #programImage> |
331 |
||
205 | 332 |
|lastResult| |
333 |
||
203 | 334 |
self theNonMetaclass isAbstract ifTrue:[^ super iconInBrowserSymbol]. |
205 | 335 |
|
336 |
lastResult := self lastTestRunResultOrNil. |
|
578 | 337 |
lastResult notNil ifTrue:[ |
630
5b0539adf1c1
comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
338 |
lastResult == TestResult statePass ifTrue:[ |
5b0539adf1c1
comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
339 |
^ #testCasePassedIcon |
5b0539adf1c1
comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
340 |
]. |
5b0539adf1c1
comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
341 |
lastResult == TestResult stateFail ifTrue:[ |
5b0539adf1c1
comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
342 |
^ #testCaseFailedIcon |
5b0539adf1c1
comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
343 |
]. |
5b0539adf1c1
comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
344 |
lastResult == TestResult stateError ifTrue:[ |
5b0539adf1c1
comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
345 |
^ #testCaseErrorIcon |
5b0539adf1c1
comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents:
628
diff
changeset
|
346 |
]. |
205 | 347 |
]. |
203 | 348 |
^ #testCaseClassIcon |
349 |
! ! |
|
350 |
||
222 | 351 |
!TestCase class methodsFor:'private'! |
352 |
||
353 |
addSelector: selector to: collection |
|
354 |
||
355 |
"Adds given selector from collection. Answers |
|
356 |
true iff selector was really added" |
|
357 |
||
594 | 358 |
(collection includes: selector) |
359 |
ifTrue:[^ false] |
|
360 |
ifFalse:[collection add: selector. ^ true] |
|
222 | 361 |
|
362 |
"Created: / 15-03-2010 / 18:06:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
363 |
"Modified: / 21-04-2010 / 23:19:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
364 |
! |
|
365 |
||
366 |
lastTestRunResultChanged: selector |
|
367 |
||
368 |
Smalltalk changed:#lastTestRunResult with:(Array with:self with:selector). |
|
369 |
self changed:#lastTestRunResult with:selector. |
|
370 |
||
371 |
"Created: / 15-03-2010 / 19:15:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
372 |
! |
|
373 |
||
374 |
testSelectors |
|
669 | 375 |
"The API method is allTestSelectors which now includes #shouldInheritSelectors and so handles all cases. Unlike that method, this does not guarantee to return a sorted ordered collection." |
222 | 376 |
|
669 | 377 |
|selectors| |
378 |
||
379 |
selectors := self sunitSelectors |
|
771
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
380 |
select: [:each | self isTestSelector: each]. |
669 | 381 |
selectors := selectors asOrderedCollection. |
382 |
selectors sort. |
|
383 |
^ selectors |
|
771
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
384 |
|
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
385 |
"Modified: / 01-09-2022 / 21:50:16 / Jan Vrany <jan.vrany@labware.com>" |
222 | 386 |
! ! |
387 |
||
417 | 388 |
!TestCase class methodsFor:'queries'! |
389 |
||
390 |
coveredClassNames |
|
391 |
"should be redefined to return a collection of classes which are tested by |
|
600 | 392 |
this suite/case. |
393 |
If not redefined, coveredPackageNames should be. |
|
599 | 394 |
|
395 |
These classes can be instrumented for coverage analysis, |
|
600 | 396 |
before running the suite to provide coverage analysis/report" |
417 | 397 |
|
398 |
^ #() |
|
399 |
||
400 |
"Created: / 06-07-2011 / 21:27:03 / cg" |
|
401 |
! |
|
402 |
||
403 |
coveredClasses |
|
600 | 404 |
"return a collection of classes which are tested by this suite/case. |
405 |
Do not redefine this; redefine either coveredClassNames or |
|
406 |
coveredPackageNames |
|
407 |
(these return names, to avoid creating |
|
408 |
a package dependecy due to the class references) |
|
599 | 409 |
|
417 | 410 |
These classes can be instrumented for coverage analysis, |
600 | 411 |
before running the suite to provide coverage analysis/report" |
417 | 412 |
|
623 | 413 |
|names| |
414 |
||
415 |
(names := self coveredPackageNames) notEmptyOrNil ifTrue:[ |
|
416 |
^ names |
|
417 |
collectAll:[:eachPackageOrPattern | |
|
418 |
eachPackageOrPattern includesMatchCharacters ifTrue:[ |
|
419 |
Smalltalk allClassesForWhich:[:cls | (cls package ?'') matches:eachPackageOrPattern]. |
|
420 |
] ifFalse:[ |
|
421 |
Smalltalk allClassesInPackage:eachPackageOrPattern |
|
422 |
] |
|
423 |
]. |
|
599 | 424 |
]. |
417 | 425 |
^ self coveredClassNames collect:[:each | Smalltalk classNamed:each] |
599 | 426 |
! |
417 | 427 |
|
599 | 428 |
coveredPackageNames |
429 |
"redefine this in a concrete testCase class to return non-nil, |
|
430 |
to return a collection of packages which are tested by this suite/case. |
|
431 |
If not redefined, coveredClassNames should be redefined. |
|
624 | 432 |
The package names may be glob patterns. |
599 | 433 |
These classes can be instrumented for coverage analysis, |
600 | 434 |
before running the suite to provide coverage analysis/report" |
599 | 435 |
|
436 |
^ nil |
|
636 | 437 |
! |
438 |
||
439 |
isAbstract |
|
440 |
"Override to true if a TestCase subclass is Abstract and should not have |
|
441 |
TestCase instances built from it" |
|
442 |
||
443 |
^self == TestCase |
|
417 | 444 |
! ! |
445 |
||
197 | 446 |
!TestCase class methodsFor:'quick testing'! |
447 |
||
448 |
assert: aBoolean |
|
449 |
^ self new assert: aBoolean |
|
450 |
||
451 |
" |
|
452 |
TestCase assert: true |
|
453 |
" |
|
454 |
! |
|
455 |
||
456 |
should: aBlock raise: anError |
|
457 |
^ self new should: aBlock raise: anError |
|
458 |
||
459 |
" |
|
460 |
TestCase should:[ self error ] raise: Error |
|
587 | 461 |
TestCase should:[ 22 ] raise: Error |
197 | 462 |
" |
463 |
! ! |
|
464 |
||
601 | 465 |
!TestCase class methodsFor:'running'! |
466 |
||
467 |
run |
|
468 |
self suite run |
|
469 |
||
470 |
" |
|
471 |
SOAP::XeXMLTests run |
|
472 |
" |
|
473 |
! ! |
|
474 |
||
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
475 |
!TestCase class methodsFor:'testing'! |
103 | 476 |
|
222 | 477 |
isTestCaseLike |
478 |
||
479 |
^true |
|
480 |
||
481 |
"Created: / 06-03-2011 / 00:16:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
482 |
! |
103 | 483 |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
484 |
rememberResult:result |
382 | 485 |
|
486 |
result outcomesDo:[:outcome|self rememberOutcome: outcome]. |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
487 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
488 |
"Created: / 05-08-2006 / 12:33:08 / cg" |
382 | 489 |
"Modified: / 20-08-2011 / 14:02:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
490 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
491 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
492 |
runTests |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
493 |
|
391 | 494 |
^self suite run |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
495 |
|
265
125e4f132d46
remember execution time (needed to generate prober reports)
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
496 |
"Modified: / 30-07-2011 / 09:26:11 / cg" |
391 | 497 |
"Modified: / 20-08-2011 / 16:14:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
498 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
499 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
500 |
shouldInheritSelectors |
594 | 501 |
"I should inherit from an Abstract superclass but not from a concrete one by default, unless I have no testSelectors in which case I must be expecting to inherit them from my superclass. If a test case with selectors wants to inherit selectors from a concrete superclass, override this to true in that subclass." |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
502 |
|
594 | 503 |
^self ~~ self lookupHierarchyRoot |
504 |
and: [self superclass isAbstract |
|
505 |
or: [self testSelectors isEmpty]] |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
506 |
! ! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
507 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
508 |
!TestCase methodsFor:'accessing'! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
509 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
510 |
resources |
594 | 511 |
"We give TestCase this instance-side method so that methods polymorphic with TestSuite can be code-identical. Having this instance-side method also helps when writing tests of resource behaviour. Except for such tests, it is rare to override this method and should not be done without thought. If there were a good reason why a single test case needed to share tests requiring different resources, it might be legitimate." |
222 | 512 |
|
594 | 513 |
^self class resources |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
514 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
515 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
516 |
selector |
594 | 517 |
^testSelector |
222 | 518 |
! |
519 |
||
520 |
shouldFork |
|
521 |
||
522 |
^self class shouldFork |
|
523 |
||
524 |
"Created: / 13-06-2011 / 16:45:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
305 | 525 |
! |
526 |
||
529 | 527 |
shouldSkip |
528 |
"Returns true, if this testcase should be skipped when a testsuite is run. |
|
648 | 529 |
This only a hint, a test runner is not obliged to respect return value. |
530 |
To skip a test, mark the method with a <skip> annotation |
|
529 | 531 |
Currently, the only user is stx/goodies/builder/reports" |
532 |
||
533 |
| method | |
|
648 | 534 |
|
529 | 535 |
method := self class lookupMethodFor: testSelector. |
536 |
method annotationsAt:#ignore orAt: #skip do:[:annotation| |
|
648 | 537 |
^true |
529 | 538 |
]. |
539 |
^false |
|
540 |
||
541 |
"Created: / 28-11-2012 / 18:03:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
542 |
! |
|
543 |
||
305 | 544 |
testCount |
545 |
||
546 |
^1 |
|
547 |
||
548 |
"Created: / 04-08-2011 / 13:03:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
549 |
! ! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
550 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
551 |
!TestCase methodsFor:'accessing & queries'! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
552 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
553 |
unfinished |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
554 |
|
594 | 555 |
"indicates an unfinished test" |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
556 |
! ! |
97 | 557 |
|
558 |
!TestCase methodsFor:'assertions'! |
|
66 | 559 |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
560 |
assert:aBlock completesInSeconds:aNumber |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
561 |
"fail, if aBlock does not finish its work in aNumber seconds" |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
562 |
|
179
caba0f640d13
context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
563 |
<resource: #skipInDebuggersWalkBack> |
caba0f640d13
context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
564 |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
565 |
|done process semaphore| |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
566 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
567 |
done := false. |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
568 |
semaphore := Semaphore new. |
174 | 569 |
process := [ |
594 | 570 |
aBlock value. |
571 |
done := true. |
|
572 |
semaphore signal |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
573 |
] fork. |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
574 |
semaphore waitWithTimeout: aNumber. |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
575 |
process terminate. |
222 | 576 |
self assert: done |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
577 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
578 |
" |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
579 |
self new assert:[Delay waitForSeconds:2] completesInSeconds:1 |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
580 |
" |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
581 |
" |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
582 |
self new assert:[Delay waitForSeconds:1] completesInSeconds:2 |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
583 |
" |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
584 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
585 |
|
222 | 586 |
assert: aBoolean message:messageIfFailing |
531 | 587 |
<resource: #skipInDebuggersWalkBack> |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
588 |
|
222 | 589 |
^self assert: aBoolean description: messageIfFailing |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
590 |
|
531 | 591 |
"Modified: / 15-12-2012 / 17:20:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
592 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
593 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
594 |
assertFalse:aBoolean |
179
caba0f640d13
context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
595 |
<resource: #skipInDebuggersWalkBack> |
caba0f640d13
context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
596 |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
597 |
^ self assert:aBoolean not |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
598 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
599 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
600 |
assertFalse:aBoolean named:testName |
179
caba0f640d13
context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
601 |
<resource: #skipInDebuggersWalkBack> |
caba0f640d13
context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
602 |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
603 |
^ self assert:aBoolean not |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
604 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
605 |
|
222 | 606 |
assertTrue:aBoolean |
179
caba0f640d13
context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
607 |
<resource: #skipInDebuggersWalkBack> |
caba0f640d13
context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
608 |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
609 |
^ self assert:aBoolean |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
610 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
611 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
612 |
assertTrue:aBoolean named:testName |
179
caba0f640d13
context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
613 |
<resource: #skipInDebuggersWalkBack> |
caba0f640d13
context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
614 |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
615 |
^ self assert:aBoolean |
66 | 616 |
! ! |
617 |
||
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
618 |
!TestCase methodsFor:'dependencies'! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
619 |
|
222 | 620 |
addDependentToHierachy: anObject |
594 | 621 |
"an empty method. for Composite compability with TestSuite" |
222 | 622 |
! |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
623 |
|
222 | 624 |
removeDependentFromHierachy: anObject |
594 | 625 |
"an empty method. for Composite compability with TestSuite" |
222 | 626 |
! ! |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
627 |
|
222 | 628 |
!TestCase methodsFor:'deprecated'! |
629 |
||
630 |
should: aBlock |
|
594 | 631 |
self assert: aBlock value |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
632 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
633 |
|
222 | 634 |
should: aBlock description: aString |
594 | 635 |
self assert: aBlock value description: aString |
222 | 636 |
! |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
637 |
|
222 | 638 |
shouldnt: aBlock |
594 | 639 |
self deny: aBlock value |
222 | 640 |
! |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
641 |
|
222 | 642 |
shouldnt: aBlock description: aString |
594 | 643 |
self deny: aBlock value description: aString |
222 | 644 |
! |
645 |
||
646 |
signalFailure: aString |
|
594 | 647 |
TestResult failure sunitSignalWith: aString. |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
648 |
! ! |
67 | 649 |
|
650 |
!TestCase methodsFor:'printing'! |
|
651 |
||
222 | 652 |
getTestName |
653 |
||
654 |
^testSelector. |
|
655 |
||
656 |
"Modified: / 05-12-2009 / 17:47:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
657 |
! |
|
658 |
||
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
659 |
name |
594 | 660 |
^ self class name. |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
661 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
662 |
|
67 | 663 |
printOn: aStream |
594 | 664 |
self class printOn:aStream. |
665 |
aStream nextPutAll: '>>#'. |
|
666 |
testSelector printOn:aStream. |
|
67 | 667 |
! ! |
668 |
||
669 |
!TestCase methodsFor:'private'! |
|
670 |
||
222 | 671 |
executeShould: aBlock inScopeOf: anExceptionalEvent |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
672 |
"/ ^[aBlock value. |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
673 |
"/ false] sunitOn: anExceptionalEvent |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
674 |
"/ do: [:ex | ex sunitExitWith: true] |
103 | 675 |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
676 |
"/ [[aBlock value] |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
677 |
"/ on: anExceptionalEvent |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
678 |
"/ do: [:ex | ^true]] |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
679 |
"/ on: TestResult exError |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
680 |
"/ do: [:ex | ^false]. |
594 | 681 |
[aBlock value] |
682 |
on: anExceptionalEvent |
|
683 |
do: [:ex | ^true]. |
|
103 | 684 |
|
594 | 685 |
^false. |
67 | 686 |
! |
687 |
||
688 |
performTest |
|
328
66cae160c956
added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
689 |
self perform: testSelector sunitAsSymbol |
67 | 690 |
! |
691 |
||
576 | 692 |
safeTearDown |
693 |
"Have to handle Abort. When tearDown is called as inside an ensure block after |
|
694 |
an abort in the debugger of an errornous test case and raises an error with a debugger |
|
695 |
itself." |
|
696 |
||
697 |
AbortOperationRequest handle:[:ex| ] do:[self tearDown]. |
|
698 |
! |
|
699 |
||
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
700 |
setTestSelector: aSymbol |
594 | 701 |
testSelector := aSymbol |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
702 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
703 |
|
222 | 704 |
signalFailure:aString resumable:isResumable |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
705 |
"/ TestResult failure sunitSignalWith: aString |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
706 |
|
179
caba0f640d13
context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
707 |
<resource: #skipInDebuggersWalkBack> |
caba0f640d13
context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
708 |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
709 |
isResumable ifTrue:[ |
594 | 710 |
TestResult resumableFailure |
711 |
raiseRequestWith:nil |
|
712 |
errorString:aString |
|
713 |
in:thisContext sender sender |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
714 |
] ifFalse:[ |
594 | 715 |
TestResult failure |
716 |
raiseErrorString:aString |
|
717 |
in:thisContext sender sender |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
718 |
]. |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
719 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
720 |
"Modified: / 06-08-2006 / 22:55:55 / cg" |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
721 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
722 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
723 |
signalUnavailableResources |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
724 |
|
222 | 725 |
self resources do:[:res | |
594 | 726 |
res isAvailable ifFalse:[ |
727 |
^ res signalInitializationError |
|
728 |
] |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
729 |
]. |
67 | 730 |
! ! |
731 |
||
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
732 |
!TestCase methodsFor:'queries'! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
733 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
734 |
isTestCase |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
735 |
^ true |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
736 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
737 |
|
221 | 738 |
isTestCaseLike |
739 |
^ true |
|
740 |
||
741 |
"Created: / 29-06-2011 / 20:37:57 / cg" |
|
742 |
! |
|
743 |
||
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
744 |
isTestSuite |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
745 |
^ false |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
746 |
! ! |
122 | 747 |
|
67 | 748 |
!TestCase methodsFor:'running'! |
749 |
||
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
750 |
debug |
382 | 751 |
|
587 | 752 |
| testCase outcome result wasProceeded| |
382 | 753 |
|
754 |
[ |
|
594 | 755 |
result := TestResult stateError. |
756 |
wasProceeded := false. |
|
587 | 757 |
|
594 | 758 |
[ |
759 |
(testCase := self class selector: testSelector) runCase. |
|
760 |
wasProceeded ifFalse:[ |
|
761 |
result := TestResult statePass. |
|
762 |
] |
|
763 |
] sunitOn:(TestResult failure) do: [:ex | |
|
764 |
ex creator == TestSkipped ifTrue:[ |
|
765 |
result := TestResult stateSkip. |
|
766 |
] ifFalse:[ |
|
767 |
result := TestResult stateFail. |
|
768 |
]. |
|
769 |
"I want a debugger to open here..." |
|
770 |
"the only really portable dialect query..." |
|
771 |
((Smalltalk respondsTo:#isSmalltalkX) and:[Smalltalk isSmalltalkX]) ifTrue:[ |
|
772 |
"/ debug |
|
773 |
Debugger |
|
774 |
enter:ex raiseContext |
|
775 |
withMessage:(ex description) |
|
776 |
mayProceed:true. |
|
777 |
wasProceeded := true. |
|
778 |
ex proceed. |
|
779 |
] ifFalse:[ |
|
780 |
"is there a portable way to open a debugger?" |
|
781 |
self halt:(ex description). |
|
782 |
wasProceeded := true. |
|
783 |
]. |
|
784 |
]. |
|
524 | 785 |
|
575 | 786 |
] sunitEnsure: [ |
594 | 787 |
" if proceeded in the debugger, we arrive here; " |
788 |
" but still, this is not always a pass !! " |
|
789 |
outcome := TestCaseOutcome new. |
|
790 |
outcome testCase: testCase. |
|
791 |
outcome result: result. |
|
792 |
outcome remember. |
|
793 |
TestResource resetResources: self resources |
|
382 | 794 |
]. |
254
7f4b9fc9756b
changed: #debug - remembers test as passed if no error occur during debugging
vrany
parents:
240
diff
changeset
|
795 |
|
7f4b9fc9756b
changed: #debug - remembers test as passed if no error occur during debugging
vrany
parents:
240
diff
changeset
|
796 |
"Modified: / 07-07-2011 / 11:10:50 / jv" |
7f4b9fc9756b
changed: #debug - remembers test as passed if no error occur during debugging
vrany
parents:
240
diff
changeset
|
797 |
"Modified: / 07-07-2011 / 11:34:08 / Jan Vrany <jan.vrant@fit.cvut,cz>" |
382 | 798 |
"Modified: / 20-08-2011 / 14:15:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
799 |
! |
67 | 800 |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
801 |
debugAsFailure |
594 | 802 |
| semaphore | |
803 |
semaphore := Semaphore new. |
|
804 |
[semaphore wait. TestResource resetResources: self resources] fork. |
|
805 |
(self class selector: testSelector) runCaseAsFailure: semaphore. |
|
67 | 806 |
! |
807 |
||
222 | 808 |
debugUsing:aSymbol |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
809 |
self signalUnavailableResources. |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
810 |
[ |
594 | 811 |
"/ used to be: |
812 |
"/ (self class selector:testSelector) perform:aSymbol |
|
813 |
"/ which is bad for subclasses which need more arguments. |
|
814 |
"/ why not use: |
|
815 |
"/ self copy perform:aSymbol |
|
816 |
"/ or even |
|
817 |
"/ self perform:aSymbol |
|
818 |
self perform:aSymbol |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
819 |
] ensure:[ |
594 | 820 |
self resources do:[:each | |
821 |
each reset |
|
822 |
] |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
823 |
] |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
824 |
! |
103 | 825 |
|
222 | 826 |
failureLog |
594 | 827 |
^SUnitNameResolver class >> #defaultLogDevice |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
828 |
! |
103 | 829 |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
830 |
isLogging |
594 | 831 |
"By default, we're not logging failures. If you override this in |
832 |
a subclass, make sure that you override #failureLog" |
|
833 |
^false |
|
222 | 834 |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
835 |
! |
103 | 836 |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
837 |
logFailure: aString |
594 | 838 |
self isLogging ifTrue: [ |
839 |
self failureLog |
|
840 |
cr; |
|
841 |
nextPutAll: aString; |
|
842 |
flush] |
|
222 | 843 |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
844 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
845 |
|
550 | 846 |
logSkipped: aString |
594 | 847 |
self isLogging ifTrue: [ |
848 |
self failureLog |
|
849 |
cr; |
|
850 |
nextPutAll: aString; |
|
851 |
flush] |
|
550 | 852 |
! |
853 |
||
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
854 |
openDebuggerOnFailingTestMethod |
594 | 855 |
"SUnit has halted one step in front of the failing test method. Step over the 'self halt' and |
856 |
send into 'self perform: testSelector' to see the failure from the beginning" |
|
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
857 |
|
594 | 858 |
self |
859 |
"/halt; |
|
860 |
performTest |
|
222 | 861 |
|
862 |
"Modified: / 05-12-2009 / 18:40:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
67 | 863 |
! |
864 |
||
865 |
run |
|
262
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
866 |
|
461
c4a68cc4e547
use TestResultForSTX in SUnit runner
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
867 |
^self run: TestResult defaultResultClass new |
262
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
868 |
|
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
869 |
"Modified: / 29-07-2011 / 12:07:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
67 | 870 |
! |
871 |
||
872 |
run: aResult |
|
262
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
873 |
|
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
874 |
^self run: aResult beforeEachDo: [:test :result|] afterEachDo: [:test :result|] |
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
875 |
|
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
876 |
"Modified: / 29-07-2011 / 12:07:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
67 | 877 |
! |
878 |
||
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
879 |
run: aResult afterEachDo:block2 |
262
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
880 |
|
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
881 |
^self run: aResult beforeEachDo: [:test :result|] afterEachDo:block2 |
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
882 |
|
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
883 |
"Modified: / 29-07-2011 / 12:07:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
884 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
885 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
886 |
run: aResult beforeEachDo:block1 afterEachDo:block2 |
262
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
887 |
|
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
888 |
^self run: aResult beforeEachDo:block1 afterEachDo:block2 resetResources: true |
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
889 |
|
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
890 |
"Modified: / 29-07-2011 / 12:06:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
891 |
! |
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
892 |
|
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
893 |
run: result beforeEachDo: before afterEachDo: after resetResources: reset |
430 | 894 |
^ self |
594 | 895 |
run: result |
896 |
beforeEachDo: before |
|
897 |
afterEachDo: after |
|
898 |
resetResources: reset |
|
899 |
debug: false |
|
430 | 900 |
|
901 |
"Created: / 29-07-2011 / 12:04:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
902 |
"Modified: / 21-08-2011 / 17:45:17 / cg" |
|
903 |
! |
|
904 |
||
905 |
run: result beforeEachDo: before afterEachDo: after resetResources: reset debug:doDebug |
|
262
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
906 |
|
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
907 |
"Workhorse for running a testcase. If reset is true, then |
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
908 |
the resources are reset, otherwise not" |
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
909 |
|
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
910 |
"1. Execute before block" |
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
911 |
"This code is ugly in Smalltalk/X but it is so because |
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
912 |
it is more portable - numArgs in ANSI (?)" |
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
913 |
before numArgs == 2 ifTrue:[ |
594 | 914 |
before value: self value: result |
262
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
915 |
] ifFalse:[ |
594 | 916 |
before numArgs == 1 ifTrue:[ |
917 |
before value: self |
|
918 |
] ifFalse:[ |
|
919 |
before value. |
|
920 |
] |
|
262
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
921 |
]. |
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
922 |
|
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
923 |
"2. Run the testcase" |
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
924 |
reset ifTrue:[ |
594 | 925 |
[ |
926 |
result runCase: self debugged:doDebug |
|
927 |
] sunitEnsure: [ |
|
928 |
TestResource resetResources: self resources |
|
929 |
]. |
|
262
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
930 |
] ifFalse:[ |
594 | 931 |
result runCase: self debugged:doDebug |
262
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
932 |
]. |
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
933 |
|
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
934 |
"3. Execute after block" |
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
935 |
"This code is ugly in Smalltalk/X but it is so because |
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
936 |
it is more portable - numArgs in ANSI (?)" |
282
deb55165e73b
changed: #run:beforeEachDo:afterEachDo:resetResources:
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
937 |
after numArgs == 2 ifTrue:[ |
594 | 938 |
after value: self value: result |
262
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
939 |
] ifFalse:[ |
594 | 940 |
after numArgs == 1 ifTrue:[ |
941 |
after value: self |
|
942 |
] ifFalse:[ |
|
943 |
after value. |
|
944 |
] |
|
262
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
945 |
]. |
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
946 |
^result |
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
947 |
|
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
948 |
"Created: / 29-07-2011 / 12:04:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
430 | 949 |
"Created: / 21-08-2011 / 17:44:56 / cg" |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
950 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
951 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
952 |
run: aResult beforeEachTestCaseDo:block1 afterEachTestCaseDo:block2 |
262
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
953 |
|
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
954 |
<resource: #obsolete> |
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
955 |
self obsoleteMethodWarning: 'Use #run:beforeEachDo:afterEachDo: instead'. |
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
956 |
|
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
957 |
^self run: aResult beforeEachDo:block1 afterEachDo:block2 |
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
958 |
|
3c46acd3f64a
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
254
diff
changeset
|
959 |
"Modified: / 29-07-2011 / 12:06:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
960 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
961 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
962 |
runCase |
570 | 963 |
|didSetup| |
964 |
||
328
66cae160c956
added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
965 |
self resources do: [:each | each availableFor: self]. |
66cae160c956
added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
966 |
|
66cae160c956
added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
967 |
[ |
594 | 968 |
didSetup := false. |
969 |
self setUp. |
|
970 |
didSetup := true. |
|
971 |
self performTest. |
|
328
66cae160c956
added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
972 |
] sunitEnsure: [ |
594 | 973 |
didSetup ifTrue:[ self safeTearDown ] |
328
66cae160c956
added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
974 |
] |
66cae160c956
added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents:
326
diff
changeset
|
975 |
|
377 | 976 |
"Modified (comment): / 18-08-2011 / 20:35:20 / cg" |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
977 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
978 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
979 |
runCaseAsFailure |
570 | 980 |
self setUp. |
981 |
[ |
|
594 | 982 |
[self openDebuggerOnFailingTestMethod] ensure: [self safeTearDown] |
570 | 983 |
] fork |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
984 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
985 |
"Modified: / 21.6.2000 / 10:04:33 / Sames" |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
986 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
987 |
|
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
988 |
runCaseAsFailure: aSemaphore |
570 | 989 |
[ |
594 | 990 |
|didSetup| |
570 | 991 |
|
594 | 992 |
didSetup := false. |
993 |
self resources do: [:each | each availableFor: self]. |
|
994 |
[ |
|
995 |
self setUp. |
|
996 |
didSetup := true. |
|
997 |
self openDebuggerOnFailingTestMethod |
|
998 |
] sunitEnsure: [ |
|
999 |
didSetup ifTrue:[ self tearDown ] |
|
1000 |
] |
|
570 | 1001 |
] sunitEnsure: [aSemaphore signal]. |
139
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
1002 |
! |
5a48f282d789
back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents:
138
diff
changeset
|
1003 |
|
67 | 1004 |
setUp |
454 | 1005 |
"can be redefined in a concrete test" |
67 | 1006 |
! |
1007 |
||
1008 |
tearDown |
|
454 | 1009 |
"can be redefined in a concrete test" |
50 | 1010 |
! ! |
1011 |
||
12 | 1012 |
!TestCase class methodsFor:'documentation'! |
1013 |
||
290 | 1014 |
version |
623 | 1015 |
^ '$Header$' |
290 | 1016 |
! |
1017 |
||
203 | 1018 |
version_CVS |
623 | 1019 |
^ '$Header$' |
222 | 1020 |
! |
1021 |
||
771
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
1022 |
version_HG |
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
1023 |
|
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
1024 |
^ '$Changeset: <not expanded> $' |
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
1025 |
! |
d1c18e4f543c
Use `#isTestSelector` in `TestCase >> #testSelectors`
Jan Vrany <jan.vrany@labware.com>
parents:
669
diff
changeset
|
1026 |
|
222 | 1027 |
version_SVN |
623 | 1028 |
^ '$Id$' |
12 | 1029 |
! ! |
81 | 1030 |
|
550 | 1031 |
|
2 | 1032 |
TestCase initialize! |