741
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
360
|
3 |
"{ Package: 'stx:goodies/sunit' }"
|
|
4 |
|
610
|
5 |
"{ NameSpace: Smalltalk }"
|
|
6 |
|
360
|
7 |
Object subclass:#TestCaseOutcome
|
|
8 |
instanceVariableNames:'testCase result properties'
|
|
9 |
classVariableNames:''
|
|
10 |
poolDictionaries:''
|
|
11 |
category:'SUnit-Base'
|
|
12 |
!
|
|
13 |
|
|
14 |
!TestCaseOutcome class methodsFor:'documentation'!
|
|
15 |
|
|
16 |
documentation
|
|
17 |
"
|
|
18 |
will keep additional info for a testCase run:
|
|
19 |
startTime, endTime,
|
|
20 |
backtrace (if fail or error)
|
|
21 |
and collectedStdout
|
|
22 |
"
|
|
23 |
! !
|
|
24 |
|
|
25 |
!TestCaseOutcome class methodsFor:'instance creation'!
|
|
26 |
|
|
27 |
forCase: aTestCase
|
|
28 |
|
|
29 |
^self new testCase: aTestCase; yourself
|
|
30 |
|
|
31 |
"Created: / 16-08-2011 / 15:24:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
32 |
! !
|
|
33 |
|
|
34 |
!TestCaseOutcome methodsFor:'accessing'!
|
|
35 |
|
|
36 |
collectedOutput
|
|
37 |
|
|
38 |
^self propertyAt: #collectedOutput
|
|
39 |
|
|
40 |
"Modified: / 16-08-2011 / 15:27:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
41 |
"Created: / 16-08-2011 / 18:19:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
42 |
!
|
|
43 |
|
|
44 |
collectedOutput: aString
|
|
45 |
|
|
46 |
^self propertyAt: #collectedOutput put: aString
|
|
47 |
|
|
48 |
"Modified: / 16-08-2011 / 15:28:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
49 |
"Created: / 16-08-2011 / 18:19:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
50 |
!
|
|
51 |
|
|
52 |
endTime
|
|
53 |
|
|
54 |
^self propertyAt: #endTime
|
|
55 |
|
|
56 |
"Modified: / 16-08-2011 / 15:28:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
57 |
!
|
|
58 |
|
|
59 |
endTime: anObject
|
|
60 |
|
|
61 |
^self propertyAt: #endTime put: anObject
|
|
62 |
|
|
63 |
"Modified: / 16-08-2011 / 15:28:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
64 |
!
|
|
65 |
|
|
66 |
exceptionDetail
|
|
67 |
|
|
68 |
^self propertyAt: #exceptionDetail
|
|
69 |
|
|
70 |
"Modified: / 16-08-2011 / 15:29:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
71 |
!
|
|
72 |
|
|
73 |
exceptionDetail: anObject
|
|
74 |
|
|
75 |
^self propertyAt: #exceptionDetail put: anObject
|
|
76 |
|
|
77 |
"Modified: / 16-08-2011 / 15:29:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
78 |
!
|
|
79 |
|
379
|
80 |
executionTime
|
741
|
81 |
"the execution time in millis;
|
|
82 |
nil if not yet executed.
|
|
83 |
If still running, the millis spent executing
|
|
84 |
is returned"
|
379
|
85 |
|
|
86 |
|startTime endTime|
|
|
87 |
|
|
88 |
(startTime := self startTime) isNil ifTrue:[
|
|
89 |
"/ not yet executed
|
|
90 |
^ nil
|
|
91 |
].
|
|
92 |
(endTime := self endTime) isNil ifTrue:[
|
|
93 |
"/ assume it is still running...
|
|
94 |
endTime := Timestamp now
|
|
95 |
].
|
589
|
96 |
^ (endTime millisecondDeltaFrom:startTime)
|
379
|
97 |
|
|
98 |
"Modified (format): / 18-08-2011 / 21:02:28 / cg"
|
741
|
99 |
"Modified (comment): / 28-03-2019 / 13:29:02 / Claus Gittinger"
|
|
100 |
!
|
|
101 |
|
|
102 |
executionTimeDuration
|
|
103 |
"the execution time as TimeDuration;
|
|
104 |
nil if not yet executed.
|
|
105 |
If still running, the time spent executing
|
|
106 |
is returned"
|
|
107 |
|
|
108 |
|startTime endTime|
|
|
109 |
|
|
110 |
(startTime := self startTime) isNil ifTrue:[
|
|
111 |
"/ not yet executed
|
|
112 |
^ nil
|
|
113 |
].
|
|
114 |
(endTime := self endTime) isNil ifTrue:[
|
|
115 |
"/ assume it is still running...
|
|
116 |
endTime := Timestamp now
|
|
117 |
].
|
|
118 |
^ (endTime - startTime)
|
|
119 |
|
|
120 |
"Created: / 28-03-2019 / 13:28:53 / Claus Gittinger"
|
379
|
121 |
!
|
|
122 |
|
360
|
123 |
propertyAt: aSymbol
|
|
124 |
|
379
|
125 |
^ self propertyAt: aSymbol ifAbsent: [nil]
|
360
|
126 |
|
|
127 |
"Created: / 16-08-2011 / 15:26:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
379
|
128 |
"Modified: / 18-08-2011 / 21:03:01 / cg"
|
360
|
129 |
!
|
|
130 |
|
|
131 |
propertyAt: aSymbol ifAbsent: aBlock
|
|
132 |
|
|
133 |
properties isNil ifTrue: [^aBlock value].
|
|
134 |
^properties at: aSymbol ifAbsent:aBlock.
|
|
135 |
|
|
136 |
"Created: / 16-08-2011 / 15:27:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
137 |
!
|
|
138 |
|
|
139 |
propertyAt: aSymbol put: anObject
|
|
140 |
|
|
141 |
properties isNil ifTrue: [properties := Dictionary new].
|
|
142 |
properties at: aSymbol put: anObject.
|
|
143 |
|
|
144 |
"Created: / 16-08-2011 / 15:28:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
145 |
!
|
|
146 |
|
|
147 |
result
|
736
|
148 |
"returns one of that state symbols:
|
|
149 |
(see stateNames on the class side)"
|
|
150 |
|
360
|
151 |
^ result
|
736
|
152 |
|
|
153 |
"Modified (comment): / 28-03-2019 / 11:29:15 / Claus Gittinger"
|
360
|
154 |
!
|
|
155 |
|
419
|
156 |
result:aSymbol
|
736
|
157 |
"sets my state symbol (see TestResult stateNames for valid names)"
|
|
158 |
|
|
159 |
self assert:(TestResult stateNames includes:aSymbol)
|
|
160 |
message:'invalid result state'.
|
|
161 |
|
419
|
162 |
result := aSymbol.
|
|
163 |
|
|
164 |
"Modified: / 20-08-2011 / 12:52:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
736
|
165 |
"Modified (comment): / 28-03-2019 / 11:30:38 / Claus Gittinger"
|
360
|
166 |
!
|
|
167 |
|
|
168 |
selector
|
|
169 |
|
|
170 |
^testCase selector
|
|
171 |
|
|
172 |
"Created: / 16-08-2011 / 15:38:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
173 |
!
|
|
174 |
|
|
175 |
startTime
|
|
176 |
|
|
177 |
^self propertyAt: #startTime
|
|
178 |
|
|
179 |
"Modified: / 16-08-2011 / 15:29:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
180 |
!
|
|
181 |
|
|
182 |
startTime: anObject
|
|
183 |
|
|
184 |
^self propertyAt: #startTime put: anObject
|
|
185 |
|
|
186 |
"Modified: / 16-08-2011 / 15:29:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
187 |
!
|
|
188 |
|
|
189 |
testCase
|
|
190 |
^ testCase
|
|
191 |
!
|
|
192 |
|
|
193 |
testCase:something
|
|
194 |
testCase := something.
|
|
195 |
! !
|
|
196 |
|
419
|
197 |
!TestCaseOutcome methodsFor:'comparing'!
|
|
198 |
|
|
199 |
= anotherOutcome
|
610
|
200 |
|myTestCase otherTestCase|
|
419
|
201 |
|
|
202 |
^(anotherOutcome isKindOf: self class)
|
610
|
203 |
and:[(myTestCase := self testCase) class == (otherTestCase := anotherOutcome testCase) class
|
|
204 |
and:[myTestCase selector == otherTestCase selector]].
|
419
|
205 |
|
|
206 |
"Created: / 20-08-2011 / 14:24:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
207 |
!
|
|
208 |
|
|
209 |
hash
|
|
210 |
|
|
211 |
^testCase hash bitXor: result hash
|
|
212 |
|
|
213 |
"Created: / 20-08-2011 / 14:23:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
214 |
! !
|
|
215 |
|
589
|
216 |
!TestCaseOutcome methodsFor:'printing & storing'!
|
|
217 |
|
|
218 |
printOn:aStream
|
662
|
219 |
"append a printed representation of the receiver to the argument, aStream"
|
589
|
220 |
|
|
221 |
super printOn:aStream.
|
|
222 |
aStream nextPut:$(.
|
|
223 |
testCase printOn: aStream.
|
|
224 |
aStream nextPut:$).
|
|
225 |
|
|
226 |
"Modified: / 17-07-2013 / 17:59:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
227 |
! !
|
|
228 |
|
419
|
229 |
!TestCaseOutcome methodsFor:'remembering'!
|
|
230 |
|
|
231 |
remember
|
|
232 |
|
|
233 |
^testCase class rememberOutcome: self.
|
|
234 |
|
|
235 |
"Created: / 20-08-2011 / 12:45:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
236 |
! !
|
|
237 |
|
360
|
238 |
!TestCaseOutcome class methodsFor:'documentation'!
|
|
239 |
|
|
240 |
version_CVS
|
662
|
241 |
^ '$Header$'
|
360
|
242 |
! !
|
589
|
243 |
|