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 |
|
44
|
44 |
^super new initialize
|
103
|
45 |
|
44
|
46 |
!
|
|
47 |
|
|
48 |
reset
|
70
|
49 |
|
103
|
50 |
current notNil ifTrue: [
|
|
51 |
[current tearDown] ensure: [
|
|
52 |
current := nil]]
|
|
53 |
|
|
54 |
!
|
|
55 |
|
|
56 |
signalInitializationError
|
|
57 |
^TestResult signalErrorWith: 'Resource ' , self name , ' could not be initialized'
|
|
58 |
|
44
|
59 |
! !
|
|
60 |
|
68
|
61 |
!TestResource class methodsFor:'testing'!
|
44
|
62 |
|
|
63 |
isAbstract
|
103
|
64 |
"Override to true if a TestResource subclass is Abstract and should not have
|
|
65 |
TestCase instances built from it"
|
|
66 |
|
180
|
67 |
^ self == TestResource
|
44
|
68 |
!
|
|
69 |
|
|
70 |
isAvailable
|
103
|
71 |
^self current notNil and: [self current isAvailable]
|
|
72 |
|
44
|
73 |
!
|
|
74 |
|
|
75 |
isUnavailable
|
103
|
76 |
|
44
|
77 |
^self isAvailable not
|
103
|
78 |
|
44
|
79 |
! !
|
|
80 |
|
68
|
81 |
!TestResource methodsFor:'accessing'!
|
44
|
82 |
|
|
83 |
description
|
103
|
84 |
|
|
85 |
description isNil
|
|
86 |
ifTrue: [^''].
|
|
87 |
|
44
|
88 |
^description
|
103
|
89 |
|
44
|
90 |
!
|
|
91 |
|
|
92 |
description: aString
|
103
|
93 |
|
44
|
94 |
description := aString
|
103
|
95 |
|
44
|
96 |
!
|
|
97 |
|
|
98 |
name
|
103
|
99 |
|
|
100 |
name isNil
|
|
101 |
ifTrue: [^self printString].
|
|
102 |
|
44
|
103 |
^name
|
103
|
104 |
|
44
|
105 |
!
|
|
106 |
|
|
107 |
name: aString
|
103
|
108 |
|
44
|
109 |
name := aString
|
103
|
110 |
|
|
111 |
!
|
|
112 |
|
|
113 |
resources
|
|
114 |
^self class resources
|
|
115 |
|
44
|
116 |
! !
|
|
117 |
|
68
|
118 |
!TestResource methodsFor:'init / release'!
|
44
|
119 |
|
|
120 |
initialize
|
103
|
121 |
self setUp
|
|
122 |
|
|
123 |
|
44
|
124 |
! !
|
|
125 |
|
68
|
126 |
!TestResource methodsFor:'printing'!
|
44
|
127 |
|
|
128 |
printOn: aStream
|
103
|
129 |
|
44
|
130 |
aStream nextPutAll: self class printString
|
103
|
131 |
|
44
|
132 |
! !
|
|
133 |
|
68
|
134 |
!TestResource methodsFor:'running'!
|
44
|
135 |
|
|
136 |
setUp
|
|
137 |
"Does nothing. Subclasses should override this
|
|
138 |
to initialize their resource"
|
103
|
139 |
|
|
140 |
!
|
|
141 |
|
|
142 |
signalInitializationError
|
|
143 |
^self class signalInitializationError
|
|
144 |
|
44
|
145 |
!
|
|
146 |
|
|
147 |
tearDown
|
|
148 |
"Does nothing. Subclasses should override this
|
|
149 |
to tear down their resource"
|
103
|
150 |
|
44
|
151 |
! !
|
|
152 |
|
68
|
153 |
!TestResource methodsFor:'testing'!
|
44
|
154 |
|
|
155 |
isAvailable
|
103
|
156 |
"override to provide information on the
|
|
157 |
readiness of the resource"
|
|
158 |
|
44
|
159 |
^true
|
103
|
160 |
|
44
|
161 |
!
|
|
162 |
|
|
163 |
isUnavailable
|
103
|
164 |
"override to provide information on the
|
|
165 |
readiness of the resource"
|
|
166 |
|
44
|
167 |
^self isAvailable not
|
103
|
168 |
|
44
|
169 |
! !
|
|
170 |
|
|
171 |
!TestResource class methodsFor:'documentation'!
|
|
172 |
|
|
173 |
version
|
180
|
174 |
^ '$Header: /cvs/stx/stx/goodies/sunit/TestResource.st,v 1.5 2008-05-27 21:02:05 cg Exp $'
|
44
|
175 |
! !
|