author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 02 Jan 2013 16:10:11 +0100 | |
branch | development |
changeset 1919 | d2f931428d34 |
parent 1858 | 6f5b593f366c |
child 1953 | 1e42ad3fc322 |
permissions | -rw-r--r-- |
877 | 1 |
" |
2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
|
1152 | 3 |
|
1155 | 4 |
New code and modifications done at SWING Research Group [1]: |
1152 | 5 |
|
877 | 6 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
7 |
SWING Research Group, Czech Technical University in Prague |
|
8 |
||
9 |
This software is furnished under a license and may be used |
|
10 |
only in accordance with the terms of that license and with the |
|
11 |
inclusion of the above copyright notice. This software may not |
|
12 |
be provided or otherwise made available to, or used by, any |
|
13 |
other person. No title to or ownership of the software is |
|
14 |
hereby transferred. |
|
15 |
||
1155 | 16 |
[1] Code written at SWING Research Group contains a signature |
17 |
of one of the above copright owners. For exact set of such code, |
|
18 |
see the differences between this version and version stx:libjava |
|
1152 | 19 |
as of 1.9.2010 |
877 | 20 |
" |
752 | 21 |
"{ Package: 'stx:libjava' }" |
22 |
||
859
56bc5e063b7d
Common code from JUnitTestCaseProxy and TestletTestCaseProxy moved to a common superclass
vranyj1
parents:
856
diff
changeset
|
23 |
JavaTestCaseProxy subclass:#JUnitTestCaseProxy |
752 | 24 |
instanceVariableNames:'' |
859
56bc5e063b7d
Common code from JUnitTestCaseProxy and TestletTestCaseProxy moved to a common superclass
vranyj1
parents:
856
diff
changeset
|
25 |
classVariableNames:'' |
752 | 26 |
poolDictionaries:'' |
859
56bc5e063b7d
Common code from JUnitTestCaseProxy and TestletTestCaseProxy moved to a common superclass
vranyj1
parents:
856
diff
changeset
|
27 |
category:'Languages-Java-Tests-Proxies' |
752 | 28 |
! |
29 |
||
877 | 30 |
!JUnitTestCaseProxy class methodsFor:'documentation'! |
31 |
||
32 |
copyright |
|
33 |
" |
|
34 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
|
1152 | 35 |
|
1155 | 36 |
New code and modifications done at SWING Research Group [1]: |
1152 | 37 |
|
877 | 38 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
39 |
SWING Research Group, Czech Technical University in Prague |
|
40 |
||
41 |
This software is furnished under a license and may be used |
|
42 |
only in accordance with the terms of that license and with the |
|
43 |
inclusion of the above copyright notice. This software may not |
|
44 |
be provided or otherwise made available to, or used by, any |
|
45 |
other person. No title to or ownership of the software is |
|
46 |
hereby transferred. |
|
47 |
||
1155 | 48 |
[1] Code written at SWING Research Group contains a signature |
49 |
of one of the above copright owners. For exact set of such code, |
|
50 |
see the differences between this version and version stx:libjava |
|
1152 | 51 |
as of 1.9.2010 |
877 | 52 |
|
53 |
" |
|
54 |
! ! |
|
752 | 55 |
|
56 |
!JUnitTestCaseProxy class methodsFor:'initialization'! |
|
57 |
||
58 |
initialize |
|
59 |
||
60 |
TestCases := Dictionary new. |
|
61 |
||
62 |
"Created: / 01-03-2011 / 10:43:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
63 |
! ! |
|
64 |
||
65 |
!JUnitTestCaseProxy class methodsFor:'accessing'! |
|
66 |
||
67 |
lookupHierarchyRoot |
|
68 |
||
69 |
^JUnitTestCaseProxy |
|
70 |
||
71 |
"Created: / 01-03-2011 / 11:41:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
72 |
"Modified: / 01-03-2011 / 14:54:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
73 |
! ! |
|
74 |
||
75 |
!JUnitTestCaseProxy class methodsFor:'private'! |
|
76 |
||
1481 | 77 |
isTestSelector: selector |
78 |
| javaClass | |
|
79 |
||
80 |
self == JUnitTestCaseProxy ifTrue:[ ^ #() ]. |
|
81 |
javaClass := self javaClass. |
|
82 |
(javaClass includesBehavior:(JavaVM classForName:'junit.framework.TestCase')) |
|
83 |
ifTrue:[ ^ selector startsWith:'test' ]. |
|
84 |
||
85 |
self testSelectors includes: selector. |
|
86 |
" |
|
87 |
(JUnitTestCase for: JAVA::stx::libjava::tests::junit::JUnit3Tests) |
|
88 |
testSelectors" |
|
89 |
||
90 |
"Created: / 17-04-2012 / 22:48:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
91 |
! |
|
92 |
||
752 | 93 |
testSelectors |
94 |
| javaClass | |
|
95 |
||
96 |
self == JUnitTestCaseProxy ifTrue:[ ^ #() ]. |
|
97 |
javaClass := self javaClass. |
|
98 |
(javaClass includesBehavior:(JavaVM classForName:'junit.framework.TestCase')) |
|
99 |
ifTrue:[ ^ javaClass selectors select:[:sel | sel startsWith:'test' ]. ]. |
|
100 |
||
101 |
^ (javaClass |
|
102 |
selectMethodsAnnotatedWith:(JavaVM classForName:'org.junit.Test') typeName) |
|
103 |
collect:[:method | method selector ] |
|
104 |
||
105 |
" |
|
106 |
(JUnitTestCase for: JAVA::stx::libjava::tests::junit::JUnit3Tests) |
|
107 |
testSelectors" |
|
108 |
||
109 |
"Created: / 01-03-2011 / 10:49:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
110 |
"Modified: / 03-03-2011 / 00:34:39 / Marcel Hlopko <hlopik@gmail.com>" |
|
111 |
"Modified: / 04-03-2011 / 00:05:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
112 |
! ! |
|
113 |
||
114 |
!JUnitTestCaseProxy class methodsFor:'subclass creation'! |
|
115 |
||
116 |
for:javaClass |
|
117 |
"Answers a new (anonymous) testcase proxy for |
|
118 |
given javaClass" |
|
119 |
||
120 |
self assert:javaClass isJavaClass description:'Not a java class'. |
|
121 |
self assert:javaClass isTestCaseLike |
|
122 |
description:'Not a testcase-like class'. |
|
859
56bc5e063b7d
Common code from JUnitTestCaseProxy and TestletTestCaseProxy moved to a common superclass
vranyj1
parents:
856
diff
changeset
|
123 |
^self forClassNamed: javaClass name |
752 | 124 |
|
125 |
"Created: / 01-03-2011 / 10:30:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
126 |
"Modified: / 03-03-2011 / 00:20:49 / Marcel Hlopko <hlopik@gmail.com>" |
|
859
56bc5e063b7d
Common code from JUnitTestCaseProxy and TestletTestCaseProxy moved to a common superclass
vranyj1
parents:
856
diff
changeset
|
127 |
"Modified: / 21-06-2011 / 17:08:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 128 |
! ! |
129 |
||
130 |
!JUnitTestCaseProxy methodsFor:'accessing'! |
|
131 |
||
855
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
132 |
nameForHDTestReport |
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
133 |
|
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
134 |
^self class javaClassName copyReplaceAll:$/ with: $. |
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
135 |
|
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
136 |
"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
|
137 |
|
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
138 |
! |
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
139 |
|
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
140 |
selectorForHDTestReport |
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
141 |
|
856 | 142 |
^testSelector upTo:$( |
855
809b1dc41615
use nameForHDTestReport and selectorForHDTestReport to identify test
vranyj1
parents:
854
diff
changeset
|
143 |
|
1858
6f5b593f366c
JUnitTestCaseProxy: added support for @Ignore annotation
vranyj1
parents:
1841
diff
changeset
|
144 |
! |
6f5b593f366c
JUnitTestCaseProxy: added support for @Ignore annotation
vranyj1
parents:
1841
diff
changeset
|
145 |
|
6f5b593f366c
JUnitTestCaseProxy: added support for @Ignore annotation
vranyj1
parents:
1841
diff
changeset
|
146 |
shouldSkip |
6f5b593f366c
JUnitTestCaseProxy: added support for @Ignore annotation
vranyj1
parents:
1841
diff
changeset
|
147 |
"Returns true, if this testcase should be skipped when a testsuite is run. |
6f5b593f366c
JUnitTestCaseProxy: added support for @Ignore annotation
vranyj1
parents:
1841
diff
changeset
|
148 |
This inly a hint, a test runner is not obliged to respect return value. |
6f5b593f366c
JUnitTestCaseProxy: added support for @Ignore annotation
vranyj1
parents:
1841
diff
changeset
|
149 |
|
6f5b593f366c
JUnitTestCaseProxy: added support for @Ignore annotation
vranyj1
parents:
1841
diff
changeset
|
150 |
Currently, the only user is stx/goodies/builder/reports" |
6f5b593f366c
JUnitTestCaseProxy: added support for @Ignore annotation
vranyj1
parents:
1841
diff
changeset
|
151 |
|
6f5b593f366c
JUnitTestCaseProxy: added support for @Ignore annotation
vranyj1
parents:
1841
diff
changeset
|
152 |
| method | |
6f5b593f366c
JUnitTestCaseProxy: added support for @Ignore annotation
vranyj1
parents:
1841
diff
changeset
|
153 |
method := self javaClass lookupMethodFor: testSelector. |
6f5b593f366c
JUnitTestCaseProxy: added support for @Ignore annotation
vranyj1
parents:
1841
diff
changeset
|
154 |
^method notNil and:[(method annotations runtimeVisible includesKey: 'Lorg/junit/Ignore;')]. |
6f5b593f366c
JUnitTestCaseProxy: added support for @Ignore annotation
vranyj1
parents:
1841
diff
changeset
|
155 |
|
6f5b593f366c
JUnitTestCaseProxy: added support for @Ignore annotation
vranyj1
parents:
1841
diff
changeset
|
156 |
"Created: / 03-12-2012 / 22:02:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 157 |
! ! |
158 |
||
159 |
!JUnitTestCaseProxy methodsFor:'private'! |
|
160 |
||
161 |
performTest |
|
162 |
||
163 |
<resource: #skipInDebuggersWalkBack> |
|
164 |
||
1839 | 165 |
| assertions | |
166 |
||
167 |
assertions := SignalSet |
|
1841 | 168 |
with: (Java classForName:'java.lang.AssertionError') |
169 |
with: (Java classForName:'junit.framework.AssertionFailedError'). |
|
752 | 170 |
[ |
1486 | 171 |
self javaClass new perform: testSelector sunitAsSymbol |
1839 | 172 |
] on: assertions do: [:ex| |
752 | 173 |
"This is the tricky part. We have to auto-magically convert |
174 |
jUnit's AssertionFailedError to sUnits TestFailure's" |
|
1839 | 175 |
TestResult failure sunitSignalWith: ex getMessage |
752 | 176 |
] |
177 |
||
178 |
"Created: / 01-03-2011 / 14:50:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1841 | 179 |
"Modified (format): / 30-11-2012 / 09:59:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 180 |
! ! |
181 |
||
182 |
!JUnitTestCaseProxy class methodsFor:'documentation'! |
|
183 |
||
184 |
version_SVN |
|
185 |
^ '$Id$' |
|
186 |
! ! |
|
187 |
||
188 |
JUnitTestCaseProxy initialize! |