author | Claus Gittinger <cg@exept.de> |
Wed, 06 Dec 2000 16:25:04 +0100 | |
changeset 6 | 78bb1397e43d |
parent 0 | 9365d5753f11 |
child 9 | e4ecc750aa38 |
permissions | -rw-r--r-- |
0 | 1 |
"{ Package: 'stx:goodies/sunit' }" |
2 |
||
3 |
TestCase subclass:#SUnitTest |
|
4 |
instanceVariableNames:'hasRun hasSetup hasRanOnce' |
|
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-Tests' |
0 | 8 |
! |
9 |
||
10 |
!SUnitTest methodsFor:'Accessing'! |
|
11 |
||
12 |
hasRun |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
13 |
^hasRun |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
14 |
! |
0 | 15 |
|
16 |
hasSetup |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
17 |
^hasSetup |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
18 |
! ! |
0 | 19 |
|
20 |
!SUnitTest methodsFor:'Private'! |
|
21 |
||
22 |
error |
|
23 |
3 zork |
|
24 |
||
25 |
"Modified: / 21.6.2000 / 10:22:18 / Sames" |
|
26 |
! |
|
27 |
||
28 |
fail |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
29 |
self assert: false |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
30 |
! |
0 | 31 |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
32 |
noop |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
33 |
! |
0 | 34 |
|
35 |
setRun |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
36 |
hasRun := true |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
37 |
! ! |
0 | 38 |
|
39 |
!SUnitTest methodsFor:'Running'! |
|
40 |
||
41 |
setUp |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
42 |
hasSetup := true |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
43 |
! ! |
0 | 44 |
|
45 |
!SUnitTest methodsFor:'Testing'! |
|
46 |
||
47 |
testAssert |
|
48 |
self assert: true. |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
49 |
self deny: false |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
50 |
! |
0 | 51 |
|
52 |
testDebugUI |
|
53 |
"This should break" |
|
54 |
3 zork |
|
55 |
||
56 |
"Modified: / 21.6.2000 / 10:22:50 / Sames" |
|
57 |
! |
|
58 |
||
59 |
testDefects |
|
60 |
| result suite error failure | |
|
61 |
suite := TestSuite new. |
|
62 |
suite addTest: (error := self class selector: #error). |
|
63 |
suite addTest: (failure := self class selector: #fail). |
|
64 |
result := suite run. |
|
65 |
self assert: result defects asArray = (Array with: error with: failure) |
|
66 |
||
67 |
"Modified: / 21.6.2000 / 10:23:04 / Sames" |
|
68 |
! |
|
69 |
||
70 |
testDialectLocalizedException |
|
71 |
self should: [TestResult signalFailureWith: 'Foo'] raise: TestResult failure. |
|
72 |
self should: [TestResult signalErrorWith: 'Foo'] raise: TestResult error. |
|
73 |
self shouldnt: [TestResult signalErrorWith: 'Foo'] raise: TestResult failure. |
|
74 |
||
75 |
"Modified: / 21.6.2000 / 10:23:20 / Sames" |
|
76 |
! |
|
77 |
||
78 |
testError |
|
79 |
| case result | |
|
80 |
case := self class selector: #error. |
|
81 |
result := case run. |
|
82 |
self assert: result correctCount = 0. |
|
83 |
self assert: result failureCount = 0. |
|
84 |
self assert: result runCount = 1. |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
85 |
self assert: result errorCount = 1 |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
86 |
! |
0 | 87 |
|
88 |
testException |
|
89 |
self should: [self error: 'foo'] raise: TestResult error |
|
90 |
||
91 |
"Modified: / 21.6.2000 / 10:23:39 / Sames" |
|
92 |
! |
|
93 |
||
94 |
testFail |
|
95 |
| case result | |
|
96 |
case := self class selector: #fail. |
|
97 |
result := case run. |
|
98 |
self assert: result correctCount = 0. |
|
99 |
self assert: result failureCount = 1. |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
100 |
self assert: result runCount = 1 |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
101 |
! |
0 | 102 |
|
103 |
testFailureDebugUI |
|
104 |
"This should fail !!" |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
105 |
self fail |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
106 |
! |
0 | 107 |
|
108 |
testIsNotRerunOnDebug |
|
109 |
| case | |
|
110 |
case := self class selector: #testRanOnlyOnce. |
|
111 |
case run. |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
112 |
case debug |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
113 |
! |
0 | 114 |
|
115 |
testRan |
|
116 |
| case | |
|
117 |
case := self class selector: #setRun. |
|
118 |
case run. |
|
119 |
self assert: case hasSetup. |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
120 |
self assert: case hasRun |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
121 |
! |
0 | 122 |
|
123 |
testRanOnlyOnce |
|
124 |
self assert: hasRanOnce ~= true. |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
125 |
hasRanOnce := true. |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
126 |
! |
0 | 127 |
|
128 |
testResult |
|
129 |
| case result | |
|
130 |
case := self class selector: #noop. |
|
131 |
result := case run. |
|
132 |
self assert: result runCount = 1. |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
133 |
self assert: result correctCount = 1 |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
134 |
! |
0 | 135 |
|
136 |
testRunning |
|
137 |
(SUnitDelay forSeconds: 2) wait |
|
138 |
||
139 |
"Modified: / 21.6.2000 / 10:24:41 / Sames" |
|
140 |
! |
|
141 |
||
142 |
testShould |
|
143 |
self should: [true]. |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
144 |
self shouldnt: [false] |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
145 |
! |
0 | 146 |
|
147 |
testSuite |
|
148 |
| suite result | |
|
149 |
suite := TestSuite new. |
|
150 |
suite addTest: (self class selector: #noop). |
|
151 |
suite addTest: (self class selector: #fail). |
|
152 |
result := suite run. |
|
153 |
self assert: result runCount = 2. |
|
154 |
self assert: result correctCount = 1. |
|
6
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
155 |
self assert: result failureCount = 1 |
78bb1397e43d
added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents:
0
diff
changeset
|
156 |
! ! |
0 | 157 |