author | vranyj1 |
Tue, 14 Jun 2011 13:25:53 +0000 | |
branch | jk_new_structure |
changeset 855 | 809b1dc41615 |
parent 854 | e165b3da9adb |
child 859 | 56bc5e063b7d |
permissions | -rw-r--r-- |
761 | 1 |
"{ Package: 'stx:libjava' }" |
2 |
||
3 |
TestCase subclass:#TestletTestCaseProxy |
|
826
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
4 |
instanceVariableNames:'harness' |
761 | 5 |
classVariableNames:'TestCases' |
6 |
poolDictionaries:'' |
|
7 |
category:'Languages-Java-JUnit' |
|
8 |
! |
|
9 |
||
853
aa9af509e506
TestletTestCaseProxy: added classvar to specify whether run the test in separate process
vranyj1
parents:
826
diff
changeset
|
10 |
TestletTestCaseProxy class instanceVariableNames:'javaClassName shouldFork' |
761 | 11 |
|
12 |
" |
|
13 |
The following class instance variables are inherited by this class: |
|
14 |
||
15 |
TestCase - lastTestRunResultOrNil lastTestRunsPassedTests lastTestRunsFailedTests lastTestRunsErrorTests |
|
16 |
TestAsserter - |
|
17 |
Object - |
|
18 |
" |
|
19 |
! |
|
20 |
||
21 |
||
22 |
!TestletTestCaseProxy class methodsFor:'initialization'! |
|
23 |
||
24 |
initialize |
|
25 |
||
26 |
TestCases := Dictionary new. |
|
27 |
||
28 |
"Created: / 01-03-2011 / 10:43:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
29 |
! |
|
30 |
||
31 |
setJavaClassName: aSymbol |
|
32 |
||
33 |
javaClassName ifNotNil: |
|
34 |
[self error: 'Attempting to set java class name twice']. |
|
35 |
javaClassName := aSymbol. |
|
36 |
||
37 |
"Created: / 01-03-2011 / 10:43:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
38 |
! ! |
|
39 |
||
40 |
!TestletTestCaseProxy class methodsFor:'accessing'! |
|
41 |
||
42 |
javaClass |
|
43 |
||
44 |
^Java at: javaClassName |
|
45 |
||
46 |
"Created: / 01-03-2011 / 11:30:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
47 |
"Modified: / 01-03-2011 / 14:48:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
48 |
! |
|
49 |
||
50 |
javaClassName |
|
51 |
||
52 |
^javaClassName |
|
53 |
||
54 |
"Created: / 01-03-2011 / 11:30:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
55 |
! |
|
56 |
||
57 |
lookupHierarchyRoot |
|
58 |
^ TestletTestCaseProxy |
|
59 |
||
60 |
"Created: / 01-03-2011 / 11:41:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
61 |
"Modified: / 01-03-2011 / 14:54:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
62 |
"Modified: / 29-04-2011 / 10:25:26 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
63 |
! |
|
64 |
||
65 |
selector: aSymbol |
|
66 |
||
67 |
^super selector: aSymbol |
|
68 |
||
69 |
"Created: / 01-03-2011 / 11:55:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
853
aa9af509e506
TestletTestCaseProxy: added classvar to specify whether run the test in separate process
vranyj1
parents:
826
diff
changeset
|
70 |
! |
aa9af509e506
TestletTestCaseProxy: added classvar to specify whether run the test in separate process
vranyj1
parents:
826
diff
changeset
|
71 |
|
aa9af509e506
TestletTestCaseProxy: added classvar to specify whether run the test in separate process
vranyj1
parents:
826
diff
changeset
|
72 |
shouldFork |
aa9af509e506
TestletTestCaseProxy: added classvar to specify whether run the test in separate process
vranyj1
parents:
826
diff
changeset
|
73 |
^ shouldFork ? false |
aa9af509e506
TestletTestCaseProxy: added classvar to specify whether run the test in separate process
vranyj1
parents:
826
diff
changeset
|
74 |
|
aa9af509e506
TestletTestCaseProxy: added classvar to specify whether run the test in separate process
vranyj1
parents:
826
diff
changeset
|
75 |
"Modified: / 13-06-2011 / 16:34:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
aa9af509e506
TestletTestCaseProxy: added classvar to specify whether run the test in separate process
vranyj1
parents:
826
diff
changeset
|
76 |
! |
aa9af509e506
TestletTestCaseProxy: added classvar to specify whether run the test in separate process
vranyj1
parents:
826
diff
changeset
|
77 |
|
aa9af509e506
TestletTestCaseProxy: added classvar to specify whether run the test in separate process
vranyj1
parents:
826
diff
changeset
|
78 |
shouldFork:something |
aa9af509e506
TestletTestCaseProxy: added classvar to specify whether run the test in separate process
vranyj1
parents:
826
diff
changeset
|
79 |
shouldFork := something. |
761 | 80 |
! ! |
81 |
||
82 |
!TestletTestCaseProxy class methodsFor:'private'! |
|
83 |
||
84 |
testSelectors |
|
85 |
"testlet always has only one test method, but maybe for the future.." |
|
86 |
||
820
beb45cce2856
Mauve test integration works.. and that's the bad news, there are sooo many failures.. so back to the beginning, let's fix natives..
hlopkmar
parents:
761
diff
changeset
|
87 |
^ #( #'test(Lgnu.testlet.TestHarness;)' ). |
761 | 88 |
|
89 |
"Created: / 01-03-2011 / 10:49:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
90 |
"Modified: / 03-03-2011 / 00:34:39 / Marcel Hlopko <hlopik@gmail.com>" |
|
91 |
"Modified: / 04-03-2011 / 00:05:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
820
beb45cce2856
Mauve test integration works.. and that's the bad news, there are sooo many failures.. so back to the beginning, let's fix natives..
hlopkmar
parents:
761
diff
changeset
|
92 |
"Modified: / 29-05-2011 / 22:54:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
761 | 93 |
! ! |
94 |
||
95 |
!TestletTestCaseProxy class methodsFor:'queries'! |
|
96 |
||
854
e165b3da9adb
Fixes for running tests in separate processes (required since VM often crash)
vranyj1
parents:
853
diff
changeset
|
97 |
isTestlet |
e165b3da9adb
Fixes for running tests in separate processes (required since VM often crash)
vranyj1
parents:
853
diff
changeset
|
98 |
^ true |
e165b3da9adb
Fixes for running tests in separate processes (required since VM often crash)
vranyj1
parents:
853
diff
changeset
|
99 |
|
e165b3da9adb
Fixes for running tests in separate processes (required since VM often crash)
vranyj1
parents:
853
diff
changeset
|
100 |
! |
e165b3da9adb
Fixes for running tests in separate processes (required since VM often crash)
vranyj1
parents:
853
diff
changeset
|
101 |
|
761 | 102 |
isAbstract |
103 |
^ self == TestletTestCaseProxy |
|
104 |
||
105 |
"Created: / 28-02-2011 / 22:32:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
106 |
"Modified: / 01-03-2011 / 14:54:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
107 |
"Modified: / 29-04-2011 / 10:21:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
108 |
! ! |
|
109 |
||
110 |
!TestletTestCaseProxy class methodsFor:'subclass creation'! |
|
111 |
||
112 |
for: javaClass |
|
113 |
"Answers a new (anonymous) testcase proxy for |
|
114 |
given javaClass" |
|
115 |
||
116 |
| meta cls name | |
|
117 |
||
118 |
self assert: javaClass isJavaClass description: 'Not a java class'. |
|
119 |
self assert: javaClass isTestletLike |
|
120 |
description: 'Not a testcase-like class'. |
|
121 |
name := javaClass name. |
|
122 |
TestCases at: name ifPresent: [:c | ^ c ]. |
|
123 |
meta := Metaclass new. |
|
124 |
meta setSuperclass: TestletTestCaseProxy class. |
|
125 |
meta instSize: TestletTestCaseProxy class instSize. |
|
126 |
cls := meta new. |
|
127 |
cls setSuperclass: TestletTestCaseProxy. |
|
128 |
cls flags: TestletTestCaseProxy flags. |
|
129 |
cls instSize: TestletTestCaseProxy instSize. |
|
130 |
cls setJavaClassName: name. |
|
131 |
cls |
|
132 |
setName: ('TestletTestCase for: (Java classForName: ' , name storeString |
|
133 |
, ')') asSymbol. |
|
134 |
cls setCategory: javaClass category. |
|
135 |
TestCases at: name put: cls. |
|
136 |
^ cls |
|
137 |
||
138 |
"Created: / 01-03-2011 / 10:30:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
139 |
"Modified: / 03-03-2011 / 00:20:49 / Marcel Hlopko <hlopik@gmail.com>" |
|
140 |
"Modified: / 01-04-2011 / 16:02:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
141 |
"Modified: / 29-04-2011 / 10:21:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
142 |
! ! |
|
143 |
||
144 |
!TestletTestCaseProxy methodsFor:'accessing'! |
|
145 |
||
146 |
javaClass |
|
147 |
||
148 |
| javaClass | |
|
149 |
||
150 |
self |
|
151 |
assert: (javaClass := self class javaClass) isJavaClass |
|
152 |
description: 'java class does not exists'. |
|
153 |
^javaClass |
|
154 |
||
155 |
"Created: / 01-03-2011 / 14:48:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
855
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
156 |
! |
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
157 |
|
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
158 |
nameForHDTestReport |
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
159 |
|
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
160 |
^(self class javaClassName copyReplaceAll:$/ with: $.) copyTo: (self class javaClassName lastIndexOf: $/) - 1. |
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
161 |
|
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
162 |
"Created: / 01-04-2011 / 16:10:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
163 |
|
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
164 |
! |
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
165 |
|
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
166 |
selectorForHDTestReport |
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
167 |
|
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
168 |
^self class javaClassName copyFrom: |
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
169 |
(self class javaClassName lastIndexOf: $/) + 1 |
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
170 |
|
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
171 |
|
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
172 |
|
761 | 173 |
! ! |
174 |
||
826
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
175 |
!TestletTestCaseProxy methodsFor:'error handling'! |
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
176 |
|
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
177 |
doesNotUnderstand: aMessage |
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
178 |
|
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
179 |
aMessage selector == #'check(Z)V' ifTrue: [ |
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
180 |
aMessage arg1 == 0 ifTrue: |
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
181 |
[TestResult failure sunitSignalWith: 'Testlet failed'] |
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
182 |
] ifFalse:[ aMessage selector == #'check(ZLjava/lang/String;)V' ifTrue:[ |
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
183 |
aMessage arg1 == 0 ifTrue: |
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
184 |
[TestResult failure sunitSignalWith: (Java as_ST_String: aMessage arguments second)] |
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
185 |
]]. |
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
186 |
(harness respondsTo: aMessage selector) ifTrue: |
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
187 |
[^aMessage sendTo: harness]. |
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
188 |
^super doesNotUnderstand: aMessage |
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
189 |
|
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
190 |
"Created: / 31-05-2011 / 16:30:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
191 |
! ! |
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
192 |
|
761 | 193 |
!TestletTestCaseProxy methodsFor:'private'! |
194 |
||
195 |
harnessMock |
|
196 |
^ (Java classForName: 'stx.libjava.tests.mocks.TestletHarnessMock') new. |
|
197 |
||
198 |
"Modified: / 29-04-2011 / 10:52:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
199 |
! |
|
200 |
||
201 |
performTest |
|
826
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
202 |
| handlerBlock | |
824 | 203 |
|
204 |
handlerBlock := [:ex | TestResult failure sunitSignalWith: ex description]. |
|
761 | 205 |
|
826
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
206 |
harness := self harnessMock. |
820
beb45cce2856
Mauve test integration works.. and that's the bad news, there are sooo many failures.. so back to the beginning, let's fix natives..
hlopkmar
parents:
761
diff
changeset
|
207 |
|
824 | 208 |
[ JavaVM unimplementedNativeMethodSignal |
209 |
handle: |
|
210 |
handlerBlock |
|
211 |
do: [ |
|
212 |
self javaClass new |
|
213 |
perform: 'test(Lgnu/testlet/TestHarness;)V' sunitAsSymbol |
|
826
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
214 |
with: self |
824 | 215 |
]. |
216 |
] on: JavaError do: [:ex | |
|
217 |
TestResult failure sunitSignalWith: ex description |
|
218 |
]. |
|
219 |
||
826
db53b9c842d7
- TestletTestCaseProxy: debugging support improved.
vranyj1
parents:
824
diff
changeset
|
220 |
"/((harness instVarNamed: 'passed') = 0 ) ifTrue: [ TestResult failure sunitSignalWith: 'Test failed' ]. |
761 | 221 |
|
222 |
"Created: / 01-03-2011 / 14:50:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
820
beb45cce2856
Mauve test integration works.. and that's the bad news, there are sooo many failures.. so back to the beginning, let's fix natives..
hlopkmar
parents:
761
diff
changeset
|
223 |
"Modified: / 29-05-2011 / 23:19:07 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
853
aa9af509e506
TestletTestCaseProxy: added classvar to specify whether run the test in separate process
vranyj1
parents:
826
diff
changeset
|
224 |
"Modified: / 13-06-2011 / 17:03:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
761 | 225 |
! ! |
226 |
||
227 |
!TestletTestCaseProxy class methodsFor:'documentation'! |
|
228 |
||
229 |
version_SVN |
|
230 |
^ '$Id$' |
|
231 |
! ! |
|
232 |
||
233 |
TestletTestCaseProxy initialize! |