"{ Package: 'stx:libjava' }"
TestCase subclass:#TestletTestCaseProxy
instanceVariableNames:''
classVariableNames:'TestCases'
poolDictionaries:''
category:'Languages-Java-JUnit'
!
TestletTestCaseProxy class instanceVariableNames:'javaClassName'
"
The following class instance variables are inherited by this class:
TestCase - lastTestRunResultOrNil lastTestRunsPassedTests lastTestRunsFailedTests lastTestRunsErrorTests
TestAsserter -
Object -
"
!
!TestletTestCaseProxy class methodsFor:'initialization'!
initialize
TestCases := Dictionary new.
"Created: / 01-03-2011 / 10:43:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
setJavaClassName: aSymbol
javaClassName ifNotNil:
[self error: 'Attempting to set java class name twice'].
javaClassName := aSymbol.
"Created: / 01-03-2011 / 10:43:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!TestletTestCaseProxy class methodsFor:'accessing'!
javaClass
^Java at: javaClassName
"Created: / 01-03-2011 / 11:30:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 01-03-2011 / 14:48:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
javaClassName
^javaClassName
"Created: / 01-03-2011 / 11:30:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
lookupHierarchyRoot
^ TestletTestCaseProxy
"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>"
"Modified: / 29-04-2011 / 10:25:26 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
nameForHDTestReport
^javaClassName copyReplaceAll:$/ with: $.
"Created: / 01-04-2011 / 16:10:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
selector: aSymbol
^super selector: aSymbol
"Created: / 01-03-2011 / 11:55:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!TestletTestCaseProxy class methodsFor:'private'!
testSelectors
"testlet always has only one test method, but maybe for the future.."
| javaClass |
self == TestletTestCaseProxy ifTrue: [ ^ #() ].
javaClass := self javaClass.
(javaClass includesBehavior: (JavaVM classForName: 'gnu.testlet.Testlet'))
ifTrue: [ ^ javaClass selectors select: [:sel | sel startsWith: 'test' ]. ]
ifFalse: [ ^ #() ].
"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>"
"Modified: / 29-04-2011 / 10:24:50 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!TestletTestCaseProxy class methodsFor:'queries'!
isAbstract
^ self == TestletTestCaseProxy
"Created: / 28-02-2011 / 22:32:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 01-03-2011 / 14:54:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 29-04-2011 / 10:21:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!TestletTestCaseProxy class methodsFor:'subclass creation'!
for: javaClass
"Answers a new (anonymous) testcase proxy for
given javaClass"
| meta cls name |
self assert: javaClass isJavaClass description: 'Not a java class'.
self assert: javaClass isTestletLike
description: 'Not a testcase-like class'.
name := javaClass name.
TestCases at: name ifPresent: [:c | ^ c ].
meta := Metaclass new.
meta setSuperclass: TestletTestCaseProxy class.
meta instSize: TestletTestCaseProxy class instSize.
cls := meta new.
cls setSuperclass: TestletTestCaseProxy.
cls flags: TestletTestCaseProxy flags.
cls instSize: TestletTestCaseProxy instSize.
cls setJavaClassName: name.
cls
setName: ('TestletTestCase for: (Java classForName: ' , name storeString
, ')') asSymbol.
cls setCategory: javaClass category.
TestCases at: name put: cls.
^ cls
"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: / 01-04-2011 / 16:02:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 29-04-2011 / 10:21:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!TestletTestCaseProxy methodsFor:'accessing'!
javaClass
| javaClass |
self
assert: (javaClass := self class javaClass) isJavaClass
description: 'java class does not exists'.
^javaClass
"Created: / 01-03-2011 / 14:48:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!TestletTestCaseProxy methodsFor:'private'!
harnessMock
^ (Java classForName: 'stx.libjava.tests.mocks.TestletHarnessMock') new.
"Modified: / 29-04-2011 / 10:52:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
performTest
| harnessMock |
harnessMock := self harnessMock.
[ self javaClass new perform: 'test(Lgnu/testlet/TestHarness;)V' sunitAsSymbol with: harnessMock ]
on: JavaError
do:
[:ex |
"This is the tricky part. We have to auto-magically convert
jUnit's AssertionFailedError to sUnits TestFailure's"
"Bad, bad, I know..."
(ex parameter class name == #'junit/framework/AssertionFailedError')
ifTrue: [ TestResult failure sunitSignalWith: ex description ]
ifFalse: [ ex pass ] ].
harnessMock instVarNamed: 'passed' = 0
ifTrue: [ TestResult failure sunitSignalWith: 'Test failed' ].
"Created: / 01-03-2011 / 14:50:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 04-03-2011 / 00:07:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 29-04-2011 / 17:39:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!TestletTestCaseProxy class methodsFor:'documentation'!
version_SVN
^ '$Id$'
! !
TestletTestCaseProxy initialize!