author | Claus Gittinger <cg@exept.de> |
Fri, 14 Dec 2001 00:08:20 +0100 | |
changeset 53 | 51abd9fe4db2 |
parent 47 | 7ea89e89bad3 |
child 68 | 9fd111438d60 |
permissions | -rw-r--r-- |
0 | 1 |
"{ Package: 'stx:goodies/sunit' }" |
2 |
||
3 |
Object subclass:#TestResult |
|
47 | 4 |
instanceVariableNames:'runCount passed failures errors' |
0 | 5 |
classVariableNames:'' |
6 |
poolDictionaries:'' |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
7 |
category:'SUnit-Base' |
0 | 8 |
! |
9 |
||
14 | 10 |
|
0 | 11 |
!TestResult class methodsFor:'Exceptions'! |
12 |
||
13 |
error |
|
14 |
^self exError |
|
15 |
||
16 |
"Modified: / 21.6.2000 / 10:07:16 / Sames" |
|
17 |
! |
|
18 |
||
19 |
exError |
|
20 |
"Change for Dialect" |
|
21 |
^Error |
|
22 |
||
23 |
"Modified: / 21.6.2000 / 10:10:45 / Sames" |
|
24 |
! |
|
25 |
||
26 |
failure |
|
27 |
^TestFailure |
|
28 |
||
29 |
"Modified: / 21.6.2000 / 10:07:03 / Sames" |
|
30 |
! |
|
31 |
||
32 |
signalErrorWith: aString |
|
33 | 33 |
self error raiseErrorString: aString |
0 | 34 |
|
35 |
"Modified: / 21.6.2000 / 10:11:07 / Sames" |
|
36 |
! |
|
37 |
||
38 |
signalFailureWith: aString |
|
33 | 39 |
self failure raiseErrorString: aString |
0 | 40 |
|
41 |
"Modified: / 21.6.2000 / 10:11:20 / Sames" |
|
42 |
! ! |
|
43 |
||
44 |
!TestResult class methodsFor:'Init / Release'! |
|
45 |
||
46 |
new |
|
47 |
^super new initialize |
|
48 |
||
49 |
"Modified: / 21.6.2000 / 10:11:50 / Sames" |
|
50 |
! ! |
|
51 |
||
52 |
!TestResult methodsFor:'Accessing'! |
|
53 |
||
54 |
correctCount |
|
53 | 55 |
"depreciated - use #passedCount" |
56 |
^self passedCount |
|
57 |
"/ ^self runCount - self failureCount - self errorCount |
|
0 | 58 |
! |
59 |
||
60 |
defects |
|
61 |
^self errors, self failures |
|
62 |
||
63 |
"Modified: / 21.6.2000 / 10:07:56 / Sames" |
|
64 |
! |
|
65 |
||
66 |
errorCount |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
67 |
^self errors size |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
68 |
! |
0 | 69 |
|
70 |
errors |
|
71 |
errors isNil ifTrue: [errors := OrderedCollection new]. |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
72 |
^errors |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
73 |
! |
0 | 74 |
|
75 |
failureCount |
|
76 |
^self failures size |
|
77 |
||
78 |
"Modified: / 21.6.2000 / 10:08:34 / Sames" |
|
79 |
! |
|
80 |
||
81 |
failures |
|
82 |
failures isNil ifTrue: [failures := OrderedCollection new]. |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
83 |
^failures |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
84 |
! |
0 | 85 |
|
53 | 86 |
passed |
87 |
passed isNil ifTrue: [passed := OrderedCollection new]. |
|
88 |
^passed |
|
89 |
! |
|
90 |
||
91 |
passedCount |
|
92 |
^ self passed size |
|
93 |
"/ ^self runCount - self failureCount - self errorCount |
|
94 |
||
95 |
"Modified: / 21.6.2000 / 10:07:48 / Sames" |
|
96 |
! |
|
97 |
||
0 | 98 |
runCount |
53 | 99 |
(self passedCount + self failureCount + self errorCount) ~~ runCount |
100 |
ifTrue:[ |
|
101 |
self halt |
|
102 |
]. |
|
103 |
||
104 |
"/ ^self passedCount + self failureCount + self errorCount |
|
105 |
^runCount |
|
106 |
! |
|
107 |
||
108 |
tests |
|
109 |
^(OrderedCollection new: self runCount) |
|
110 |
addAll: self passed; |
|
111 |
addAll: self errors; |
|
112 |
addAll: self defects; |
|
113 |
yourself |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
114 |
! ! |
0 | 115 |
|
116 |
!TestResult methodsFor:'Init / Release'! |
|
117 |
||
118 |
initialize |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
119 |
runCount := 0 |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
120 |
! ! |
0 | 121 |
|
122 |
!TestResult methodsFor:'Printing'! |
|
123 |
||
124 |
printOn: aStream |
|
125 |
aStream |
|
126 |
nextPutAll: self runCount printString; |
|
127 |
nextPutAll: ' run, '; |
|
53 | 128 |
nextPutAll: self passedCount printString; |
129 |
nextPutAll: ' passed, '; |
|
0 | 130 |
nextPutAll: self failureCount printString; |
131 |
nextPutAll: ' failed, '; |
|
132 |
nextPutAll: self errorCount printString; |
|
133 |
nextPutAll:' error'. |
|
134 |
self errorCount ~= 1 |
|
135 |
ifTrue: [aStream nextPut: $s]. |
|
136 |
! ! |
|
137 |
||
138 |
!TestResult methodsFor:'Running'! |
|
139 |
||
140 |
runCase: aTestCase |
|
53 | 141 |
|testCasePassed| |
142 |
||
18 | 143 |
runCount := runCount + 1. |
53 | 144 |
[ |
145 |
[aTestCase runCase. |
|
146 |
testCasePassed := true.] |
|
18 | 147 |
on: self class failure |
53 | 148 |
do:[:signal | |
149 |
self failures add: aTestCase. |
|
150 |
testCasePassed := false. |
|
151 |
signal returnWith: false] |
|
152 |
] |
|
153 |
on: self class error |
|
154 |
do:[:signal | |
|
155 |
self errors add: aTestCase. |
|
156 |
testCasePassed := false. |
|
157 |
signal returnWith: false]. |
|
158 |
||
159 |
testCasePassed ifTrue: [self passed add: aTestCase] |
|
0 | 160 |
|
161 |
"Modified: / 21.6.2000 / 10:10:06 / Sames" |
|
162 |
! ! |
|
163 |
||
164 |
!TestResult methodsFor:'Testing'! |
|
165 |
||
53 | 166 |
hasErrors |
167 |
||
168 |
^self errors size > 0 |
|
169 |
! |
|
170 |
||
171 |
hasFailures |
|
172 |
||
173 |
^self failures size > 0 |
|
174 |
! |
|
175 |
||
0 | 176 |
hasPassed |
53 | 177 |
^self hasErrors not and: [self hasFailures not] |
178 |
"/ ^self runCount = self correctCount |
|
179 |
! |
|
180 |
||
181 |
isError: aTestCase |
|
182 |
||
183 |
^self errors includes: aTestCase |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
184 |
! |
0 | 185 |
|
186 |
isFailure: aTestCase |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
187 |
^self failures includes: aTestCase |
53 | 188 |
! |
189 |
||
190 |
isPassed: aTestCase |
|
191 |
||
192 |
^self passed includes: aTestCase |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
193 |
! ! |
0 | 194 |
|
14 | 195 |
!TestResult class methodsFor:'documentation'! |
196 |
||
197 |
version |
|
53 | 198 |
^ '$Header: /cvs/stx/stx/goodies/sunit/TestResult.st,v 1.8 2001-12-13 23:08:20 cg Exp $' |
14 | 199 |
! ! |