TestCase.st
changeset 570 c9c4c97948cc
parent 565 0bcfed632d51
child 573 428c2391c132
--- a/TestCase.st	Wed Apr 17 20:42:06 2013 +0200
+++ b/TestCase.st	Wed Apr 17 20:42:26 2013 +0200
@@ -856,31 +856,45 @@
 !
 
 runCase
+    |didSetup|
+
     self resources do: [:each | each availableFor: self].
 
     [
+        didSetup := false.
         self setUp.
+        didSetup := true.
         self performTest.
     ] sunitEnsure: [
-        self tearDown
+        didSetup ifTrue:[ self tearDown ]
     ]
 
     "Modified (comment): / 18-08-2011 / 20:35:20 / cg"
 !
 
 runCaseAsFailure
-        self setUp.
-        [[self openDebuggerOnFailingTestMethod] ensure: [self tearDown]] fork
+    self setUp.
+    [
+        [self openDebuggerOnFailingTestMethod] ensure: [self tearDown]
+    ] fork
 
     "Modified: / 21.6.2000 / 10:04:33 / Sames"
 !
 
 runCaseAsFailure: aSemaphore
-        [self resources do: [:each | each availableFor: self].
-        [self setUp.
-        self openDebuggerOnFailingTestMethod]
-                sunitEnsure: [self tearDown]]
-                        sunitEnsure: [aSemaphore signal].
+    [
+        |didSetup|
+
+        didSetup := false.
+        self resources do: [:each | each availableFor: self].
+        [
+            self setUp.
+            didSetup := true.
+            self openDebuggerOnFailingTestMethod
+        ] sunitEnsure: [
+            didSetup ifTrue:[ self tearDown ]
+        ]
+    ] sunitEnsure: [aSemaphore signal].
 !
 
 setUp
@@ -894,11 +908,11 @@
 !TestCase class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestCase.st,v 1.97 2013-04-03 13:58:07 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestCase.st,v 1.98 2013-04-17 18:42:26 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestCase.st,v 1.97 2013-04-03 13:58:07 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestCase.st,v 1.98 2013-04-17 18:42:26 cg Exp $'
 !
 
 version_SVN