TestResult refactoring - now it allow for more fine-grained customization
authorvrany
Wed, 03 Aug 2011 16:31:42 +0200
changeset 300 570aed392231
parent 299 4f7577ca5364
child 301 921572c655e1
TestResult refactoring - now it allow for more fine-grained customization
TestResult.st
--- a/TestResult.st	Wed Aug 03 13:04:13 2011 +0200
+++ b/TestResult.st	Wed Aug 03 16:31:42 2011 +0200
@@ -61,6 +61,19 @@
 	^errors
 !
 
+exceptions
+
+    "Returns a set of exceptions to be handled. Bu default,
+     failure and generic error is handled. This method may
+     be overriden by custom TestResult subclasses to add more.
+     For example, a 'self halt' is not handled by default
+     exceptions set"
+
+    ^self class failure , self class error
+
+    "Created: / 03-08-2011 / 14:11:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 failureCount
 
 	^self failures size
@@ -115,23 +128,43 @@
 
 !TestResult methodsFor:'adding'!
 
-addError: aTestCase
-	aTestCase class rememberErrorTest: aTestCase selector.
-	^self errors add: aTestCase
+addError: testcase detail: detail
+
+        "Called when a test outcome is error. testCase 
+         is the errorneous testcase, detail is platform
+         specific object describing the error. Actually, 
+         on all platforms exept GemStone, detail is an instance 
+         of an exception that caused the error"
+
+        "JV2011-08-03: TODO: Validate the comment above with GS,
+         possibly change name to 'exception'"
+
+        testcase class rememberErrorTest: testcase selector.
+        ^self errors add: testcase
 
     "Modified: / 11-09-2010 / 17:19:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 03-08-2011 / 13:50:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-addFailure: aTestCase
-	aTestCase class rememberFailedTest: aTestCase selector.
-	^self failures add: aTestCase
+addFailure: testcase detail: detail
+
+        "Called when a test fails. testCase is the failed 
+         testcase, detail is platform specific object describing 
+         the failure. Actually, on all platforms exept GemStone, 
+         detail is an instance of an exception that caused the failure"
 
-    "Modified: / 11-09-2010 / 17:18:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+        "JV2011-08-03: TODO: Validate the comment above with GS,
+         possibly change name to 'exception'"
+
+        testcase class rememberFailedTest: testcase selector.
+        ^self failures add: testcase
+
+    "Created: / 03-08-2011 / 13:53:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-addPass: aTestCase
-	aTestCase class rememberPassedTest: aTestCase selector.
-	^self passed add: aTestCase
+addPass: testcase
+        testcase class rememberPassedTest: testcase selector.
+        ^self passed add: testcase
 
     "Modified: / 11-09-2010 / 17:19:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
@@ -199,16 +232,31 @@
 
 !TestResult methodsFor:'running'!
 
+doRunCase: aTestCase
+
+    "Actually runs the case. The TestCase>>runCase itself calls
+     a setUp/tearDown methods. The possible error/failure is handled
+     in TestResult>>runCase:. This method is meant to be overriden by
+     custom TestResult subclasses."
+
+    aTestCase runCase.
+
+    "Modified: / 02-08-2011 / 18:10:09 / cg"
+    "Created: / 03-08-2011 / 14:02:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 runCase: aTestCase
-        [aTestCase runCase.
+
+        [self doRunCase: aTestCase.
         self addPass: aTestCase]
-                sunitOn: self class failure , self class error
+                sunitOn: self exceptions
                 do: [:ex | 
                     aTestCase exceptionInfoString:(self exceptionInfoStringFor:ex in:aTestCase).
                     ex sunitAnnounce: aTestCase toResult: self
                 ].
 
     "Modified: / 02-08-2011 / 18:10:09 / cg"
+    "Modified: / 03-08-2011 / 14:08:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !TestResult methodsFor:'testing'!
@@ -245,11 +293,11 @@
 !TestResult class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResult.st,v 1.24 2011-08-02 18:14:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResult.st,v 1.25 2011-08-03 14:31:42 vrany Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResult.st,v 1.24 2011-08-02 18:14:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResult.st,v 1.25 2011-08-03 14:31:42 vrany Exp $'
 !
 
 version_SVN