author | Claus Gittinger <cg@exept.de> |
Tue, 04 Sep 2001 21:03:35 +0200 | |
changeset 33 | 1a5d44e6c9c5 |
parent 32 | 77f76ea3a7ef |
child 47 | 7ea89e89bad3 |
permissions | -rw-r--r-- |
0 | 1 |
"{ Package: 'stx:goodies/sunit' }" |
2 |
||
3 |
Object subclass:#TestResult |
|
4 |
instanceVariableNames:'runCount failures errors' |
|
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 |
|
55 |
^self runCount - self failureCount - self errorCount |
|
56 |
||
57 |
"Modified: / 21.6.2000 / 10:07:48 / Sames" |
|
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 |
|
86 |
runCount |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
87 |
^runCount |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
88 |
! ! |
0 | 89 |
|
90 |
!TestResult methodsFor:'Init / Release'! |
|
91 |
||
92 |
initialize |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
93 |
runCount := 0 |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
94 |
! ! |
0 | 95 |
|
96 |
!TestResult methodsFor:'Printing'! |
|
97 |
||
98 |
printOn: aStream |
|
99 |
aStream |
|
100 |
nextPutAll: self runCount printString; |
|
101 |
nextPutAll: ' run, '; |
|
102 |
nextPutAll: self failureCount printString; |
|
103 |
nextPutAll: ' failed, '; |
|
104 |
nextPutAll: self errorCount printString; |
|
105 |
nextPutAll:' error'. |
|
106 |
self errorCount ~= 1 |
|
107 |
ifTrue: [aStream nextPut: $s]. |
|
108 |
||
109 |
"Created: / 21.6.2000 / 10:09:12 / Sames" |
|
110 |
! ! |
|
111 |
||
112 |
!TestResult methodsFor:'Running'! |
|
113 |
||
114 |
runCase: aTestCase |
|
18 | 115 |
runCount := runCount + 1. |
116 |
[[aTestCase runCase] |
|
117 |
on: self class failure |
|
118 |
do: |
|
119 |
[:signal | |
|
120 |
self failures add: aTestCase. |
|
32 | 121 |
signal returnWith: nil]] |
18 | 122 |
on: self class error |
123 |
do: |
|
124 |
[:signal | |
|
125 |
self errors add: aTestCase. |
|
32 | 126 |
signal returnWith: nil] |
0 | 127 |
|
128 |
"Modified: / 21.6.2000 / 10:10:06 / Sames" |
|
129 |
! ! |
|
130 |
||
131 |
!TestResult methodsFor:'Testing'! |
|
132 |
||
133 |
hasPassed |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
134 |
^self runCount = self correctCount |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
135 |
! |
0 | 136 |
|
137 |
isFailure: aTestCase |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
138 |
^self failures includes: aTestCase |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
139 |
! ! |
0 | 140 |
|
14 | 141 |
!TestResult class methodsFor:'documentation'! |
142 |
||
143 |
version |
|
33 | 144 |
^ '$Header: /cvs/stx/stx/goodies/sunit/TestResult.st,v 1.6 2001-09-04 19:03:35 cg Exp $' |
14 | 145 |
! ! |