author | vrany |
Fri, 29 Jul 2011 13:14:04 +0200 | |
changeset 263 | 31c7107b5edd |
parent 243 | cbce69b15370 |
child 271 | 6b971d5e95b8 |
permissions | -rw-r--r-- |
0 | 1 |
"{ Package: 'stx:goodies/sunit' }" |
2 |
||
3 |
Object subclass:#TestSuite |
|
103 | 4 |
instanceVariableNames:'tests resources name' |
0 | 5 |
classVariableNames:'' |
6 |
poolDictionaries:'' |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
7 |
category:'SUnit-Base' |
0 | 8 |
! |
9 |
||
222 | 10 |
TestSuite comment:'' |
103 | 11 |
! |
14 | 12 |
|
103 | 13 |
|
222 | 14 |
!TestSuite class methodsFor:'instance creation'! |
56 | 15 |
|
16 |
named: aString |
|
103 | 17 |
|
18 |
^self new |
|
19 |
name: aString; |
|
20 |
yourself |
|
56 | 21 |
! ! |
22 |
||
68 | 23 |
!TestSuite methodsFor:'accessing'! |
0 | 24 |
|
25 |
addTest: aTest |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
26 |
self tests add: aTest |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
27 |
! |
0 | 28 |
|
222 | 29 |
addTests: aCollection |
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
30 |
aCollection do: [:eachTest | self addTest: eachTest] |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
31 |
! |
0 | 32 |
|
47 | 33 |
defaultResources |
222 | 34 |
^self tests |
35 |
inject: OrderedCollection new |
|
36 |
into: |
|
37 |
[:coll :testCase | |
|
38 |
testCase resources do: |
|
39 |
[:each | |
|
40 |
(coll includes: each) ifFalse: [coll add: each]]. |
|
41 |
coll] |
|
42 |
! |
|
43 |
||
44 |
getTestName |
|
45 |
^self name |
|
46 |
||
47 |
"Created: / 12-09-2006 / 11:38:09 / cg" |
|
47 | 48 |
! |
49 |
||
37 | 50 |
name |
103 | 51 |
|
222 | 52 |
^name |
37 | 53 |
! |
54 |
||
103 | 55 |
name: aString |
56 |
||
57 |
name := aString |
|
37 | 58 |
! |
59 |
||
137 | 60 |
nameOfTest |
61 |
^ self name |
|
62 |
! |
|
63 |
||
47 | 64 |
resources |
65 |
resources isNil ifTrue: [resources := self defaultResources]. |
|
66 |
^resources |
|
67 |
! |
|
68 |
||
222 | 69 |
resources: someOrderedTestResourceClasses |
70 |
"The parameter should understand reverseDo: and should not contain duplicates." |
|
47 | 71 |
|
222 | 72 |
resources := someOrderedTestResourceClasses |
140 | 73 |
! |
74 |
||
0 | 75 |
tests |
76 |
tests isNil ifTrue: [tests := OrderedCollection new]. |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
77 |
^tests |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
78 |
! ! |
0 | 79 |
|
68 | 80 |
!TestSuite methodsFor:'dependencies'! |
0 | 81 |
|
82 |
addDependentToHierachy: anObject |
|
222 | 83 |
self sunitAddDependent: anObject. |
84 |
self tests do: [ :each | each addDependentToHierachy: anObject] |
|
0 | 85 |
! |
86 |
||
87 |
removeDependentFromHierachy: anObject |
|
222 | 88 |
self sunitRemoveDependent: anObject. |
89 |
self tests do: [ :each | each removeDependentFromHierachy: anObject] |
|
0 | 90 |
! ! |
91 |
||
122 | 92 |
!TestSuite methodsFor:'queries'! |
93 |
||
94 |
isTestCase |
|
95 |
^ false |
|
96 |
! |
|
97 |
||
98 |
isTestSuite |
|
99 |
^ true |
|
100 |
! ! |
|
101 |
||
68 | 102 |
!TestSuite methodsFor:'running'! |
0 | 103 |
|
104 |
run |
|
103 | 105 |
|
263
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
106 |
^self run: TestResult new. |
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
107 |
|
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
108 |
"Modified: / 29-07-2011 / 09:34:31 / 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
|
109 |
! |
0 | 110 |
|
263
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
111 |
run:aTestResult |
222 | 112 |
|
263
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
113 |
^self run: aTestResult |
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
114 |
beforeEachDo: [:test :result|] |
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
115 |
afterEachDo: [:test :result|] |
222 | 116 |
|
263
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
117 |
"Modified: / 29-07-2011 / 09:59:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
40 | 118 |
! |
119 |
||
263
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
120 |
run:result beforeEachDo: before afterEachDo: after |
222 | 121 |
|
263
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
122 |
result name:name. |
222 | 123 |
[ |
243
cbce69b15370
changed: #run:beforeEachDo:afterEachDo:
Claus Gittinger <cg@exept.de>
parents:
238
diff
changeset
|
124 |
self tests do:[:each | |
cbce69b15370
changed: #run:beforeEachDo:afterEachDo:
Claus Gittinger <cg@exept.de>
parents:
238
diff
changeset
|
125 |
self sunitChanged:each. |
263
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
126 |
each run:result |
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
127 |
beforeEachDo: before |
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
128 |
afterEachDo: after |
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
129 |
resetResources: false "I'll reset it, see the ensure below" |
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
130 |
] |
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
131 |
] sunitEnsure:[ |
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
132 |
TestResource resetResources: self resources |
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
133 |
]. |
202 | 134 |
|
263
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
135 |
^result |
222 | 136 |
|
243
cbce69b15370
changed: #run:beforeEachDo:afterEachDo:
Claus Gittinger <cg@exept.de>
parents:
238
diff
changeset
|
137 |
"Modified: / 06-07-2011 / 14:24:45 / cg" |
263
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
138 |
"Modified: / 29-07-2011 / 12:09:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
122 | 139 |
! |
140 |
||
222 | 141 |
run:aResult beforeEachTestCaseDo:block1 afterEachTestCaseDo:block2 |
142 |
||
263
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
143 |
<resource: #obsolete> |
222 | 144 |
|
263
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
145 |
^self run: aResult beforeEachDo: block1 afterEachDo: block2 |
222 | 146 |
|
263
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
147 |
"Modified: / 29-07-2011 / 09:49:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
238 | 148 |
! |
149 |
||
150 |
runBeforeEachDo:block1 afterEachDo: block2 |
|
263
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
151 |
|
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
152 |
^self run: TestResult new beforeEachDo: block1 afterEachDo: block2 |
238 | 153 |
|
154 |
"Created: / 05-07-2011 / 16:51:25 / cg" |
|
263
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
155 |
"Modified: / 29-07-2011 / 09:51:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 156 |
! ! |
157 |
||
68 | 158 |
!TestSuite methodsFor:'testing'! |
49 | 159 |
|
160 |
areAllResourcesAvailable |
|
222 | 161 |
^self resources |
49 | 162 |
inject: true |
163 |
into: [:total :each | each isAvailable & total] |
|
103 | 164 |
! |
165 |
||
166 |
signalUnavailableResources |
|
167 |
||
222 | 168 |
self resources do:[:res | |
169 |
res isAvailable ifFalse:[ |
|
170 |
^ res signalInitializationError |
|
171 |
] |
|
103 | 172 |
]. |
49 | 173 |
! ! |
174 |
||
14 | 175 |
!TestSuite class methodsFor:'documentation'! |
176 |
||
243
cbce69b15370
changed: #run:beforeEachDo:afterEachDo:
Claus Gittinger <cg@exept.de>
parents:
238
diff
changeset
|
177 |
version_CVS |
263
31c7107b5edd
TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents:
243
diff
changeset
|
178 |
^ '$Header: /cvs/stx/stx/goodies/sunit/TestSuite.st,v 1.22 2011-07-29 11:14:04 vrany Exp $' |
222 | 179 |
! |
180 |
||
181 |
version_SVN |
|
182 |
^ '§Id: TestSuite.st 203 2010-09-11 14:49:03Z vranyj1 §' |
|
14 | 183 |
! ! |