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