src/TestletTestCaseProxy.st
branchjk_new_structure
changeset 820 beb45cce2856
parent 761 43e017ec7958
child 824 26e719a7e88c
equal deleted inserted replaced
819:d95b67600835 820:beb45cce2856
    78 
    78 
    79 !TestletTestCaseProxy class methodsFor:'private'!
    79 !TestletTestCaseProxy class methodsFor:'private'!
    80 
    80 
    81 testSelectors
    81 testSelectors
    82     "testlet always has only one test method, but maybe for the future.."
    82     "testlet always has only one test method, but maybe for the future.."
    83     | javaClass |
       
    84 
    83 
    85     self == TestletTestCaseProxy ifTrue: [ ^ #() ].
    84     ^ #( #'test(Lgnu.testlet.TestHarness;)' ).
    86     javaClass := self javaClass.
       
    87     (javaClass includesBehavior: (JavaVM classForName: 'gnu.testlet.Testlet')) 
       
    88         ifTrue: [ ^ javaClass selectors select: [:sel | sel startsWith: 'test' ]. ]
       
    89         ifFalse: [ ^ #() ].
       
    90 
    85 
    91     "Created: / 01-03-2011 / 10:49:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    86     "Created: / 01-03-2011 / 10:49:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    92     "Modified: / 03-03-2011 / 00:34:39 / Marcel Hlopko <hlopik@gmail.com>"
    87     "Modified: / 03-03-2011 / 00:34:39 / Marcel Hlopko <hlopik@gmail.com>"
    93     "Modified: / 04-03-2011 / 00:05:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    88     "Modified: / 04-03-2011 / 00:05:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    94     "Modified: / 29-04-2011 / 10:24:50 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
    89     "Modified: / 29-05-2011 / 22:54:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
    95 ! !
    90 ! !
    96 
    91 
    97 !TestletTestCaseProxy class methodsFor:'queries'!
    92 !TestletTestCaseProxy class methodsFor:'queries'!
    98 
    93 
    99 isAbstract
    94 isAbstract
   162 
   157 
   163 performTest
   158 performTest
   164     | harnessMock |
   159     | harnessMock |
   165 
   160 
   166     harnessMock := self harnessMock.
   161     harnessMock := self harnessMock.
   167     [ self javaClass new perform: 'test(Lgnu/testlet/TestHarness;)V' sunitAsSymbol with: harnessMock ] 
   162     
   168         on: JavaError
   163     [ self javaClass new 
   169         do: 
   164         perform: 'test(Lgnu/testlet/TestHarness;)V' sunitAsSymbol
   170             [:ex | 
   165         with: harnessMock ] on: JavaError
   171             "This is the tricky part. We have to auto-magically convert
   166             do: 
   172              jUnit's AssertionFailedError to sUnits TestFailure's"
   167                 [:ex | TestResult failure sunitSignalWith: ex description].
   173             "Bad, bad, I know..."
   168     ((harnessMock instVarNamed: 'passed') = 0 ) ifTrue: [ TestResult failure sunitSignalWith: 'Test failed' ].
   174             (ex parameter class name == #'junit/framework/AssertionFailedError') 
       
   175                 ifTrue: [ TestResult failure sunitSignalWith: ex description ]
       
   176                 ifFalse: [ ex pass ] ].
       
   177     harnessMock instVarNamed: 'passed' = 0
       
   178         ifTrue: [ TestResult failure sunitSignalWith: 'Test failed' ].
       
   179 
   169 
   180     "Created: / 01-03-2011 / 14:50:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   170     "Created: / 01-03-2011 / 14:50:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   181     "Modified: / 04-03-2011 / 00:07:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   171     "Modified: / 04-03-2011 / 00:07:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   182     "Modified: / 29-04-2011 / 17:39:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
   172     "Modified: / 29-05-2011 / 23:19:07 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
   183 ! !
   173 ! !
   184 
   174 
   185 !TestletTestCaseProxy class methodsFor:'documentation'!
   175 !TestletTestCaseProxy class methodsFor:'documentation'!
   186 
   176 
   187 version_SVN
   177 version_SVN