0
|
1 |
'From Smalltalk/X, Version:4.1.1 on 24-oct-2000 at 08:10:32 pm' !
|
|
2 |
|
|
3 |
"{ Package: 'stx:goodies/sunit' }"
|
|
4 |
|
|
5 |
Object subclass:#TestResult
|
|
6 |
instanceVariableNames:'runCount failures errors'
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'SUnit'
|
|
10 |
!
|
|
11 |
|
|
12 |
!TestResult class methodsFor:'Exceptions'!
|
|
13 |
|
|
14 |
error
|
|
15 |
^self exError
|
|
16 |
|
|
17 |
"Modified: / 21.6.2000 / 10:07:16 / Sames"
|
|
18 |
!
|
|
19 |
|
|
20 |
exError
|
|
21 |
"Change for Dialect"
|
|
22 |
^Error
|
|
23 |
|
|
24 |
"Modified: / 21.6.2000 / 10:10:45 / Sames"
|
|
25 |
!
|
|
26 |
|
|
27 |
failure
|
|
28 |
^TestFailure
|
|
29 |
|
|
30 |
"Modified: / 21.6.2000 / 10:07:03 / Sames"
|
|
31 |
!
|
|
32 |
|
|
33 |
signalErrorWith: aString
|
|
34 |
self error sunitSignalWith: aString
|
|
35 |
|
|
36 |
"Modified: / 21.6.2000 / 10:11:07 / Sames"
|
|
37 |
!
|
|
38 |
|
|
39 |
signalFailureWith: aString
|
|
40 |
self failure sunitSignalWith: aString
|
|
41 |
|
|
42 |
"Modified: / 21.6.2000 / 10:11:20 / Sames"
|
|
43 |
! !
|
|
44 |
|
|
45 |
!TestResult class methodsFor:'Init / Release'!
|
|
46 |
|
|
47 |
new
|
|
48 |
^super new initialize
|
|
49 |
|
|
50 |
"Modified: / 21.6.2000 / 10:11:50 / Sames"
|
|
51 |
! !
|
|
52 |
|
|
53 |
!TestResult methodsFor:'Accessing'!
|
|
54 |
|
|
55 |
correctCount
|
|
56 |
^self runCount - self failureCount - self errorCount
|
|
57 |
|
|
58 |
"Modified: / 21.6.2000 / 10:07:48 / Sames"
|
|
59 |
!
|
|
60 |
|
|
61 |
defects
|
|
62 |
^self errors, self failures
|
|
63 |
|
|
64 |
"Modified: / 21.6.2000 / 10:07:56 / Sames"
|
|
65 |
!
|
|
66 |
|
|
67 |
errorCount
|
|
68 |
^self errors size!
|
|
69 |
|
|
70 |
errors
|
|
71 |
errors isNil ifTrue: [errors := OrderedCollection new].
|
|
72 |
^errors!
|
|
73 |
|
|
74 |
failureCount
|
|
75 |
^self failures size
|
|
76 |
|
|
77 |
"Modified: / 21.6.2000 / 10:08:34 / Sames"
|
|
78 |
!
|
|
79 |
|
|
80 |
failures
|
|
81 |
failures isNil ifTrue: [failures := OrderedCollection new].
|
|
82 |
^failures!
|
|
83 |
|
|
84 |
runCount
|
|
85 |
^runCount! !
|
|
86 |
|
|
87 |
!TestResult methodsFor:'Init / Release'!
|
|
88 |
|
|
89 |
initialize
|
|
90 |
runCount := 0! !
|
|
91 |
|
|
92 |
!TestResult methodsFor:'Printing'!
|
|
93 |
|
|
94 |
printOn: aStream
|
|
95 |
aStream
|
|
96 |
nextPutAll: self runCount printString;
|
|
97 |
nextPutAll: ' run, ';
|
|
98 |
nextPutAll: self failureCount printString;
|
|
99 |
nextPutAll: ' failed, ';
|
|
100 |
nextPutAll: self errorCount printString;
|
|
101 |
nextPutAll:' error'.
|
|
102 |
self errorCount ~= 1
|
|
103 |
ifTrue: [aStream nextPut: $s].
|
|
104 |
|
|
105 |
"Created: / 21.6.2000 / 10:09:12 / Sames"
|
|
106 |
! !
|
|
107 |
|
|
108 |
!TestResult methodsFor:'Running'!
|
|
109 |
|
|
110 |
runCase: aTestCase
|
|
111 |
runCount := runCount + 1.
|
|
112 |
[[aTestCase runCase]
|
|
113 |
sunitOn: self class failure
|
|
114 |
do:
|
|
115 |
[:signal |
|
|
116 |
self failures add: aTestCase.
|
|
117 |
signal sunitExitWith: nil]]
|
|
118 |
sunitOn: self class error
|
|
119 |
do:
|
|
120 |
[:signal |
|
|
121 |
self errors add: aTestCase.
|
|
122 |
signal sunitExitWith: nil]
|
|
123 |
|
|
124 |
"Modified: / 21.6.2000 / 10:10:06 / Sames"
|
|
125 |
! !
|
|
126 |
|
|
127 |
!TestResult methodsFor:'Testing'!
|
|
128 |
|
|
129 |
hasPassed
|
|
130 |
^self runCount = self correctCount!
|
|
131 |
|
|
132 |
isFailure: aTestCase
|
|
133 |
^self failures includes: aTestCase! !
|
|
134 |
|