44
|
1 |
"{ Package: 'stx:goodies/sunit' }"
|
|
2 |
|
|
3 |
Object subclass:#TestResource
|
|
4 |
instanceVariableNames:'name description'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'SUnit-Base'
|
|
8 |
!
|
|
9 |
|
|
10 |
TestResource class instanceVariableNames:'current'
|
|
11 |
|
|
12 |
"
|
|
13 |
No other class instance variables are inherited by this class.
|
|
14 |
"
|
|
15 |
!
|
|
16 |
|
|
17 |
|
68
|
18 |
!TestResource class methodsFor:'accessing'!
|
44
|
19 |
|
|
20 |
current
|
103
|
21 |
|
|
22 |
current isNil
|
|
23 |
ifTrue: [current := self new].
|
|
24 |
|
44
|
25 |
^current
|
103
|
26 |
|
44
|
27 |
!
|
|
28 |
|
|
29 |
current: aTestResource
|
103
|
30 |
|
44
|
31 |
current := aTestResource
|
103
|
32 |
|
|
33 |
!
|
|
34 |
|
|
35 |
resources
|
|
36 |
^#()
|
|
37 |
|
44
|
38 |
! !
|
|
39 |
|
68
|
40 |
!TestResource class methodsFor:'creation'!
|
44
|
41 |
|
|
42 |
new
|
103
|
43 |
|
217
|
44 |
^self basicNew initialize
|
44
|
45 |
!
|
|
46 |
|
|
47 |
reset
|
70
|
48 |
|
103
|
49 |
current notNil ifTrue: [
|
|
50 |
[current tearDown] ensure: [
|
|
51 |
current := nil]]
|
|
52 |
|
|
53 |
!
|
|
54 |
|
|
55 |
signalInitializationError
|
|
56 |
^TestResult signalErrorWith: 'Resource ' , self name , ' could not be initialized'
|
|
57 |
|
44
|
58 |
! !
|
|
59 |
|
68
|
60 |
!TestResource class methodsFor:'testing'!
|
44
|
61 |
|
|
62 |
isAbstract
|
103
|
63 |
"Override to true if a TestResource subclass is Abstract and should not have
|
|
64 |
TestCase instances built from it"
|
|
65 |
|
180
|
66 |
^ self == TestResource
|
44
|
67 |
!
|
|
68 |
|
|
69 |
isAvailable
|
103
|
70 |
^self current notNil and: [self current isAvailable]
|
|
71 |
|
44
|
72 |
!
|
|
73 |
|
|
74 |
isUnavailable
|
103
|
75 |
|
44
|
76 |
^self isAvailable not
|
103
|
77 |
|
44
|
78 |
! !
|
|
79 |
|
68
|
80 |
!TestResource methodsFor:'accessing'!
|
44
|
81 |
|
|
82 |
description
|
103
|
83 |
|
|
84 |
description isNil
|
|
85 |
ifTrue: [^''].
|
|
86 |
|
44
|
87 |
^description
|
103
|
88 |
|
44
|
89 |
!
|
|
90 |
|
|
91 |
description: aString
|
103
|
92 |
|
44
|
93 |
description := aString
|
103
|
94 |
|
44
|
95 |
!
|
|
96 |
|
|
97 |
name
|
103
|
98 |
|
|
99 |
name isNil
|
|
100 |
ifTrue: [^self printString].
|
|
101 |
|
44
|
102 |
^name
|
103
|
103 |
|
44
|
104 |
!
|
|
105 |
|
|
106 |
name: aString
|
103
|
107 |
|
44
|
108 |
name := aString
|
103
|
109 |
|
|
110 |
!
|
|
111 |
|
|
112 |
resources
|
|
113 |
^self class resources
|
|
114 |
|
44
|
115 |
! !
|
|
116 |
|
68
|
117 |
!TestResource methodsFor:'init / release'!
|
44
|
118 |
|
|
119 |
initialize
|
103
|
120 |
self setUp
|
|
121 |
|
|
122 |
|
44
|
123 |
! !
|
|
124 |
|
68
|
125 |
!TestResource methodsFor:'printing'!
|
44
|
126 |
|
|
127 |
printOn: aStream
|
103
|
128 |
|
44
|
129 |
aStream nextPutAll: self class printString
|
103
|
130 |
|
44
|
131 |
! !
|
|
132 |
|
68
|
133 |
!TestResource methodsFor:'running'!
|
44
|
134 |
|
|
135 |
setUp
|
|
136 |
"Does nothing. Subclasses should override this
|
|
137 |
to initialize their resource"
|
103
|
138 |
|
|
139 |
!
|
|
140 |
|
|
141 |
signalInitializationError
|
|
142 |
^self class signalInitializationError
|
|
143 |
|
44
|
144 |
!
|
|
145 |
|
|
146 |
tearDown
|
|
147 |
"Does nothing. Subclasses should override this
|
|
148 |
to tear down their resource"
|
103
|
149 |
|
44
|
150 |
! !
|
|
151 |
|
68
|
152 |
!TestResource methodsFor:'testing'!
|
44
|
153 |
|
|
154 |
isAvailable
|
103
|
155 |
"override to provide information on the
|
|
156 |
readiness of the resource"
|
|
157 |
|
44
|
158 |
^true
|
103
|
159 |
|
44
|
160 |
!
|
|
161 |
|
|
162 |
isUnavailable
|
103
|
163 |
"override to provide information on the
|
|
164 |
readiness of the resource"
|
|
165 |
|
44
|
166 |
^self isAvailable not
|
103
|
167 |
|
44
|
168 |
! !
|
|
169 |
|
|
170 |
!TestResource class methodsFor:'documentation'!
|
|
171 |
|
|
172 |
version
|
217
|
173 |
^ '$Header: /cvs/stx/stx/goodies/sunit/TestResource.st,v 1.6 2010-06-14 11:01:11 cg Exp $'
|
|
174 |
!
|
|
175 |
|
|
176 |
version_CVS
|
|
177 |
^ '$Header: /cvs/stx/stx/goodies/sunit/TestResource.st,v 1.6 2010-06-14 11:01:11 cg Exp $'
|
44
|
178 |
! !
|