Use smalltalk on:do: to catch Java exceptions development
authorvranyj1
Thu, 29 Nov 2012 22:54:43 +0000
branchdevelopment
changeset 1839 9dba543140c3
parent 1838 a8439d2b4344
child 1840 abd3746f821f
Use smalltalk on:do: to catch Java exceptions
JUnitTestCaseProxy.st
--- a/JUnitTestCaseProxy.st	Thu Nov 29 22:49:31 2012 +0000
+++ b/JUnitTestCaseProxy.st	Thu Nov 29 22:54:43 2012 +0000
@@ -149,22 +149,22 @@
 
     <resource: #skipInDebuggersWalkBack>
 
+    | assertions |
+
+    assertions := SignalSet 
+                    with: JAVA java lang AssertionError
+                    with: JAVA junit framework AssertionFailedError.
+
     [
         self javaClass new perform: testSelector sunitAsSymbol
-    ] on: JavaError do: [:ex|
+    ] on: assertions 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 ]
+        TestResult failure sunitSignalWith: ex getMessage
     ]
 
     "Created: / 01-03-2011 / 14:50:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 05-05-2012 / 22:12:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 29-11-2012 / 22:18:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JUnitTestCaseProxy class methodsFor:'documentation'!