"
COPYRIGHT (c) 1996-2011 by Claus Gittinger
New code and modifications done at SWING Research Group [1]:
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
SWING Research Group, Czech Technical University in Prague
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
[1] Code written at SWING Research Group contains a signature
of one of the above copright owners. For exact set of such code,
see the differences between this version and version stx:libjava
as of 1.9.2010
"
"{ Package: 'stx:libjava' }"
JavaTestCaseProxy subclass:#JUnitTestCaseProxy
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'Languages-Java-Tests-Proxies'
!
!JUnitTestCaseProxy class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1996-2011 by Claus Gittinger
New code and modifications done at SWING Research Group [1]:
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
SWING Research Group, Czech Technical University in Prague
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
[1] Code written at SWING Research Group contains a signature
of one of the above copright owners. For exact set of such code,
see the differences between this version and version stx:libjava
as of 1.9.2010
"
! !
!JUnitTestCaseProxy class methodsFor:'initialization'!
initialize
TestCases := Dictionary new.
"Created: / 01-03-2011 / 10:43:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JUnitTestCaseProxy class methodsFor:'accessing'!
lookupHierarchyRoot
^JUnitTestCaseProxy
"Created: / 01-03-2011 / 11:41:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 01-03-2011 / 14:54:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JUnitTestCaseProxy class methodsFor:'private'!
isTestSelector: selector
| javaClass |
self == JUnitTestCaseProxy ifTrue:[ ^ #() ].
javaClass := self javaClass.
(javaClass includesBehavior:(JavaVM classForName:'junit.framework.TestCase'))
ifTrue:[ ^ selector startsWith:'test' ].
self testSelectors includes: selector.
"
(JUnitTestCase for: JAVA::stx::libjava::tests::junit::JUnit3Tests)
testSelectors"
"Created: / 17-04-2012 / 22:48:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
testSelectors
| javaClass |
self == JUnitTestCaseProxy ifTrue:[ ^ #() ].
javaClass := self javaClass.
(javaClass includesBehavior:(JavaVM classForName:'junit.framework.TestCase'))
ifTrue:[ ^ javaClass selectors select:[:sel | sel startsWith:'test' ]. ].
^ (javaClass
selectMethodsAnnotatedWith:(JavaVM classForName:'org.junit.Test') typeName)
collect:[:method | method selector ]
"
(JUnitTestCase for: JAVA::stx::libjava::tests::junit::JUnit3Tests)
testSelectors"
"Created: / 01-03-2011 / 10:49:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 03-03-2011 / 00:34:39 / Marcel Hlopko <hlopik@gmail.com>"
"Modified: / 04-03-2011 / 00:05:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JUnitTestCaseProxy class methodsFor:'subclass creation'!
for:javaClass
"Answers a new (anonymous) testcase proxy for
given javaClass"
self assert:javaClass isJavaClass description:'Not a java class'.
self assert:javaClass isTestCaseLike
description:'Not a testcase-like class'.
^self forClassNamed: javaClass name
"Created: / 01-03-2011 / 10:30:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 03-03-2011 / 00:20:49 / Marcel Hlopko <hlopik@gmail.com>"
"Modified: / 21-06-2011 / 17:08:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JUnitTestCaseProxy methodsFor:'accessing'!
nameForHDTestReport
^self class javaClassName copyReplaceAll:$/ with: $.
"Created: / 01-04-2011 / 16:10:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
selectorForHDTestReport
^testSelector upTo:$(
!
shouldSkip
"Returns true, if this testcase should be skipped when a testsuite is run.
This inly a hint, a test runner is not obliged to respect return value.
Currently, the only user is stx/goodies/builder/reports"
| method |
method := self javaClass lookupMethodFor: testSelector.
^method notNil and:[(method annotations runtimeVisible includesKey: 'Lorg/junit/Ignore;')].
"Created: / 03-12-2012 / 22:02:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JUnitTestCaseProxy methodsFor:'private'!
performTest
<resource: #skipInDebuggersWalkBack>
| assertions |
assertions := SignalSet
with: (Java classForName:'java.lang.AssertionError')
with: (Java classForName:'junit.framework.AssertionFailedError').
[
self javaClass new perform: testSelector sunitAsSymbol
] on: assertions do: [:ex|
"This is the tricky part. We have to auto-magically convert
jUnit's AssertionFailedError to sUnits TestFailure's"
TestResult failure sunitSignalWith: ex getMessage
]
"Created: / 01-03-2011 / 14:50:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified (format): / 30-11-2012 / 09:59:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JUnitTestCaseProxy class methodsFor:'documentation'!
version_CVS
^ '$Header: /cvs/stx/stx/libjava/JUnitTestCaseProxy.st,v 1.4 2013-09-06 00:41:08 vrany Exp $'
!
version_HG
^ '$Changeset: <not expanded> $'
!
version_SVN
^ '§Id§'
! !
JUnitTestCaseProxy initialize!