108
|
1 |
"{ Package: 'stx:goodies/sunit' }"
|
|
2 |
|
|
3 |
TestCase subclass:#SimpleTestResourceTestCase
|
|
4 |
instanceVariableNames:'resource'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'SUnit-Tests'
|
|
8 |
!
|
|
9 |
|
|
10 |
TestResource subclass:#SimpleTestResource
|
|
11 |
instanceVariableNames:'runningState hasRun hasSetup hasRanOnce'
|
|
12 |
classVariableNames:''
|
|
13 |
poolDictionaries:''
|
|
14 |
privateIn:SimpleTestResourceTestCase
|
|
15 |
!
|
|
16 |
|
|
17 |
|
|
18 |
!SimpleTestResourceTestCase class methodsFor:'Not categorized'!
|
|
19 |
|
|
20 |
resources
|
|
21 |
^Set new add: SimpleTestResource; yourself
|
|
22 |
|
|
23 |
! !
|
|
24 |
|
|
25 |
!SimpleTestResourceTestCase methodsFor:'Not categorized'!
|
|
26 |
|
|
27 |
dummy
|
|
28 |
self assert: true
|
|
29 |
|
|
30 |
!
|
|
31 |
|
|
32 |
error
|
|
33 |
'foo' odd
|
|
34 |
|
|
35 |
!
|
|
36 |
|
|
37 |
fail
|
|
38 |
self assert: false
|
|
39 |
|
|
40 |
!
|
|
41 |
|
|
42 |
setRun
|
|
43 |
resource setRun
|
|
44 |
|
|
45 |
!
|
|
46 |
|
|
47 |
setUp
|
|
48 |
resource := SimpleTestResource current
|
|
49 |
|
|
50 |
!
|
|
51 |
|
|
52 |
testRan
|
|
53 |
| case |
|
|
54 |
|
|
55 |
case := self class selector: #setRun.
|
|
56 |
case run.
|
|
57 |
self assert: resource hasSetup.
|
|
58 |
self assert: resource hasRun
|
|
59 |
|
|
60 |
!
|
|
61 |
|
|
62 |
testResourceInitRelease
|
|
63 |
| result suite error failure |
|
|
64 |
suite := TestSuite new.
|
|
65 |
suite addTest: (error := self class selector: #error).
|
|
66 |
suite addTest: (failure := self class selector: #fail).
|
|
67 |
suite addTest: (self class selector: #dummy).
|
|
68 |
result := suite run.
|
|
69 |
self assert: resource hasSetup
|
|
70 |
|
|
71 |
!
|
|
72 |
|
|
73 |
testResourcesCollection
|
|
74 |
| collection |
|
|
75 |
collection := self resources.
|
|
76 |
self assert: collection size = 1
|
|
77 |
|
|
78 |
! !
|
|
79 |
|
|
80 |
!SimpleTestResourceTestCase::SimpleTestResource methodsFor:'accessing'!
|
|
81 |
|
|
82 |
runningState
|
|
83 |
|
|
84 |
^runningState
|
|
85 |
|
|
86 |
!
|
|
87 |
|
|
88 |
runningState: aSymbol
|
|
89 |
|
|
90 |
runningState := aSymbol
|
|
91 |
|
|
92 |
! !
|
|
93 |
|
|
94 |
!SimpleTestResourceTestCase::SimpleTestResource methodsFor:'running'!
|
|
95 |
|
|
96 |
setRun
|
|
97 |
hasRun := true
|
|
98 |
|
|
99 |
!
|
|
100 |
|
|
101 |
setUp
|
|
102 |
|
|
103 |
self runningState: self startedStateSymbol.
|
|
104 |
hasSetup := true
|
|
105 |
|
|
106 |
!
|
|
107 |
|
|
108 |
startedStateSymbol
|
|
109 |
|
|
110 |
^#started
|
|
111 |
|
|
112 |
!
|
|
113 |
|
|
114 |
stoppedStateSymbol
|
|
115 |
|
|
116 |
^#stopped
|
|
117 |
|
|
118 |
!
|
|
119 |
|
|
120 |
tearDown
|
|
121 |
|
|
122 |
self runningState: self stoppedStateSymbol
|
|
123 |
|
|
124 |
! !
|
|
125 |
|
|
126 |
!SimpleTestResourceTestCase::SimpleTestResource methodsFor:'testing'!
|
|
127 |
|
|
128 |
hasRun
|
|
129 |
^hasRun
|
|
130 |
|
|
131 |
!
|
|
132 |
|
|
133 |
hasSetup
|
|
134 |
^hasSetup
|
|
135 |
|
|
136 |
!
|
|
137 |
|
|
138 |
isAvailable
|
|
139 |
|
|
140 |
^self runningState == self startedStateSymbol
|
|
141 |
|
|
142 |
! !
|
|
143 |
|
|
144 |
!SimpleTestResourceTestCase class methodsFor:'documentation'!
|
|
145 |
|
|
146 |
version
|
|
147 |
^ '$Header: /cvs/stx/stx/goodies/sunit/SimpleTestResourceTestCase.st,v 1.1 2003-09-26 16:01:01 stefan Exp $'
|
|
148 |
! !
|