author | Claus Gittinger <cg@exept.de> |
Tue, 05 Jul 2011 18:24:33 +0200 | |
changeset 242 | 708d1d633192 |
parent 222 | 8e6f482297fa |
child 270 | edb137bd861e |
permissions | -rw-r--r-- |
0 | 1 |
"{ Package: 'stx:goodies/sunit' }" |
2 |
||
3 |
Object subclass:#TestResult |
|
222 | 4 |
instanceVariableNames:'name timestamp failures errors passed' |
104 | 5 |
classVariableNames:'' |
6 |
poolDictionaries:'' |
|
7 |
category:'SUnit-Base' |
|
8 |
! |
|
9 |
||
222 | 10 |
TestResult comment:'' |
0 | 11 |
! |
12 |
||
14 | 13 |
|
222 | 14 |
!TestResult class methodsFor:'instance creation'! |
15 |
||
16 |
new |
|
17 |
^super new initialize |
|
18 |
! ! |
|
19 |
||
68 | 20 |
!TestResult class methodsFor:'exceptions'! |
0 | 21 |
|
22 |
error |
|
104 | 23 |
^self exError |
0 | 24 |
! |
25 |
||
26 |
exError |
|
104 | 27 |
^SUnitNameResolver errorObject |
0 | 28 |
! |
29 |
||
30 |
failure |
|
104 | 31 |
^TestFailure |
32 |
! |
|
0 | 33 |
|
104 | 34 |
resumableFailure |
35 |
^ResumableTestFailure |
|
0 | 36 |
! |
37 |
||
222 | 38 |
signalErrorWith: aString |
39 |
self error sunitSignalWith: aString |
|
40 |
! |
|
0 | 41 |
|
222 | 42 |
signalFailureWith: aString |
43 |
self failure sunitSignalWith: aString |
|
0 | 44 |
! ! |
45 |
||
242 | 46 |
!TestResult class methodsFor:'others'! |
47 |
||
48 |
version_CVS |
|
49 |
^ '$Header: /cvs/stx/stx/goodies/sunit/TestResult.st,v 1.21 2011-07-05 16:24:33 cg Exp $' |
|
50 |
! ! |
|
51 |
||
68 | 52 |
!TestResult methodsFor:'accessing'! |
0 | 53 |
|
54 |
defects |
|
104 | 55 |
^OrderedCollection new |
56 |
addAll: self errors; |
|
57 |
addAll: self failures; yourself |
|
0 | 58 |
! |
59 |
||
60 |
errorCount |
|
104 | 61 |
|
62 |
^self errors size |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
63 |
! |
0 | 64 |
|
65 |
errors |
|
222 | 66 |
errors isNil ifTrue: [errors := OrderedCollection new]. |
104 | 67 |
^errors |
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
68 |
! |
0 | 69 |
|
70 |
failureCount |
|
71 |
||
104 | 72 |
^self failures size |
0 | 73 |
! |
74 |
||
75 |
failures |
|
222 | 76 |
"We use a Set, not an OrderedCollection as #errors and #passed do, because a resumable test failure in a loop can raise many failures against the same test. In current Sunit UIs, this could result in bizarre test count reporting (-27 tests run, and suchlike). This will be reviewed." |
77 |
||
78 |
failures isNil ifTrue: [failures := Set new]. |
|
104 | 79 |
^failures |
222 | 80 |
! |
81 |
||
82 |
name |
|
83 |
^ name |
|
84 |
! |
|
85 |
||
86 |
name:aString |
|
87 |
name := aString. |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
88 |
! |
0 | 89 |
|
53 | 90 |
passed |
222 | 91 |
passed isNil ifTrue: [passed := OrderedCollection new]. |
104 | 92 |
^passed |
53 | 93 |
! |
94 |
||
95 |
passedCount |
|
96 |
||
104 | 97 |
^self passed size |
53 | 98 |
! |
99 |
||
0 | 100 |
runCount |
53 | 101 |
|
104 | 102 |
^self passedCount + self failureCount + self errorCount |
53 | 103 |
! |
104 |
||
105 |
tests |
|
104 | 106 |
|
107 |
^(OrderedCollection new: self runCount) |
|
108 |
addAll: self passed; |
|
109 |
addAll: self errors; |
|
110 |
addAll: self failures; |
|
111 |
yourself |
|
222 | 112 |
! |
113 |
||
114 |
timestamp |
|
115 |
^ timestamp |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
116 |
! ! |
0 | 117 |
|
222 | 118 |
!TestResult methodsFor:'adding'! |
119 |
||
120 |
addError: aTestCase |
|
121 |
aTestCase class rememberErrorTest: aTestCase selector. |
|
122 |
^self errors add: aTestCase |
|
123 |
||
124 |
"Modified: / 11-09-2010 / 17:19:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
125 |
! |
|
126 |
||
127 |
addFailure: aTestCase |
|
128 |
aTestCase class rememberFailedTest: aTestCase selector. |
|
129 |
^self failures add: aTestCase |
|
130 |
||
131 |
"Modified: / 11-09-2010 / 17:18:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
132 |
! |
|
133 |
||
134 |
addPass: aTestCase |
|
135 |
aTestCase class rememberPassedTest: aTestCase selector. |
|
136 |
^self passed add: aTestCase |
|
137 |
||
138 |
"Modified: / 11-09-2010 / 17:19:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
139 |
! ! |
|
140 |
||
141 |
!TestResult methodsFor:'deprecated'! |
|
142 |
||
143 |
correctCount |
|
144 |
"deprecated - use #passedCount" |
|
145 |
||
146 |
^self passedCount |
|
147 |
! ! |
|
148 |
||
149 |
!TestResult methodsFor:'initialize-release'! |
|
0 | 150 |
|
151 |
initialize |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
152 |
! ! |
0 | 153 |
|
68 | 154 |
!TestResult methodsFor:'printing'! |
0 | 155 |
|
156 |
printOn: aStream |
|
104 | 157 |
|
158 |
aStream |
|
159 |
nextPutAll: self runCount printString; |
|
160 |
nextPutAll: ' run, '; |
|
161 |
nextPutAll: self correctCount printString; |
|
162 |
nextPutAll: ' passed, '; |
|
163 |
nextPutAll: self failureCount printString; |
|
164 |
nextPutAll: ' failed, '; |
|
165 |
nextPutAll: self errorCount printString; |
|
166 |
nextPutAll: ' error'. |
|
167 |
||
168 |
self errorCount ~= 1 |
|
169 |
ifTrue: [aStream nextPut: $s] |
|
0 | 170 |
! ! |
171 |
||
68 | 172 |
!TestResult methodsFor:'running'! |
0 | 173 |
|
222 | 174 |
runCase: aTestCase |
175 |
[aTestCase runCase. |
|
176 |
self addPass: aTestCase] |
|
177 |
sunitOn: self class failure , self class error |
|
178 |
do: [:ex | ex sunitAnnounce: aTestCase toResult: self]. |
|
0 | 179 |
! ! |
180 |
||
68 | 181 |
!TestResult methodsFor:'testing'! |
0 | 182 |
|
53 | 183 |
hasErrors |
184 |
||
104 | 185 |
^self errors size > 0 |
53 | 186 |
! |
187 |
||
188 |
hasFailures |
|
189 |
||
104 | 190 |
^self failures size > 0 |
53 | 191 |
! |
192 |
||
0 | 193 |
hasPassed |
104 | 194 |
|
195 |
^self hasErrors not and: [self hasFailures not] |
|
53 | 196 |
! |
197 |
||
198 |
isError: aTestCase |
|
199 |
||
104 | 200 |
^self errors includes: aTestCase |
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
201 |
! |
0 | 202 |
|
203 |
isFailure: aTestCase |
|
104 | 204 |
^self failures includes: aTestCase |
53 | 205 |
! |
206 |
||
207 |
isPassed: aTestCase |
|
208 |
||
104 | 209 |
^self passed includes: aTestCase |
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
210 |
! ! |
0 | 211 |
|
14 | 212 |
!TestResult class methodsFor:'documentation'! |
213 |
||
214 |
version |
|
242 | 215 |
^ '$Header: /cvs/stx/stx/goodies/sunit/TestResult.st,v 1.21 2011-07-05 16:24:33 cg Exp $' |
222 | 216 |
! |
217 |
||
218 |
version_SVN |
|
219 |
^ '§Id: TestResult.st 205 2010-09-11 15:23:01Z vranyj1 §' |
|
14 | 220 |
! ! |