class: TestCase
authorClaus Gittinger <cg@exept.de>
Thu, 08 Nov 2012 00:04:08 +0100
changeset 523 dbbf2521cc0c
parent 522 3582d5e59c14
child 524 5cf0a462356a
class: TestCase added: #testSelectorSkipped: changed:5 methods
TestCase.st
--- a/TestCase.st	Wed Nov 07 22:21:56 2012 +0100
+++ b/TestCase.st	Thu Nov 08 00:04:08 2012 +0100
@@ -148,28 +148,33 @@
         ^TestCase
 !
 
-rememberOutcome: outcome
+rememberOutcome: thisOutcome
+    |thisTestCase someOtherOutcome someOtherTestCase|
+
+    thisTestCase := thisOutcome testCase.
 
     lastOutcomes isNil ifTrue:[
         lastOutcomes := OrderedCollection new.
     ].
 
-    "Not a nice code, but portable..."
+    "Not a nice code, but portable (what: doWithIndex: is not portable?)"
     1 to: lastOutcomes size do:[:i|
-        | each |
-
-        each := lastOutcomes at: i.
-        (each testCase class name = outcome testCase class name
-        and: [each testCase selector == outcome testCase selector]) ifTrue:[
-            lastOutcomes at: i put: outcome.
-            each result ~= outcome result ifTrue:[
-                self lastTestRunResultChanged: outcome selector. 
+        someOtherOutcome := lastOutcomes at: i.
+        someOtherTestCase := someOtherOutcome testCase.
+        "/ compare by classes name - in case it got redefined
+        (someOtherTestCase class name = thisTestCase class name
+        and: [someOtherTestCase selector == thisTestCase selector]) ifTrue:[
+            "remember; for the timestamp and other info"
+            lastOutcomes at: i put: thisOutcome.
+            someOtherOutcome result ~= thisOutcome result ifTrue:[
+                "but only send out change notification to browser if state has changed"
+                self lastTestRunResultChanged: thisOutcome selector. 
             ].
             ^self.                    
         ].
     ].
-    lastOutcomes add: outcome.
-    self lastTestRunResultChanged: outcome selector.
+    lastOutcomes add: thisOutcome.
+    self lastTestRunResultChanged: thisOutcome selector.
     ^self
 
     "Created: / 20-08-2011 / 12:43:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -203,37 +208,48 @@
 !
 
 testSelector:selector result: result
+    "return true, if the last run of this test had the outcome result"
 
     lastOutcomes isNil ifTrue:[^false].
-    ^(lastOutcomes 
-        detect:[:each|
-            each testCase class name = self name
-                and:[each testCase selector == selector
-                    and:[each result == result]]
+    ^ lastOutcomes 
+        contains:[:any|
+            any testCase class name = self name
+            and:[any testCase selector == selector
+            and:[any result == result]]
         ]
-        ifNone: [nil]) notNil
 
     "Created: / 20-08-2011 / 16:15:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 04-06-2012 / 16:12:17 / cg"
 !
 
 testSelectorError:selector
+    "return true, if the last run of this test failed"
 
-    ^self testSelector: selector result: #error
+    ^self testSelector: selector result: (TestResult stateError)
 
     "Created: / 15-03-2010 / 19:44:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 testSelectorFailed:selector
+    "return true, if the last run of this test failed"
 
-    ^self testSelector: selector result: #fail
+    ^self testSelector: selector result: (TestResult stateFail)
 
     "Modified: / 20-08-2011 / 16:16:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 testSelectorPassed:selector
+    "return true, if the last run of this test passed"
 
-   ^self testSelector: selector result: #pass
+   ^self testSelector: selector result: (TestResult statePass)
+
+    "Created: / 15-03-2010 / 17:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+testSelectorSkipped:selector
+    "return true, if the last run of this test was skipped"
+
+   ^self testSelector: selector result: (TestResult stateSkip)
 
     "Created: / 15-03-2010 / 17:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
@@ -836,11 +852,11 @@
 !TestCase class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestCase.st,v 1.88 2012-11-05 21:04:14 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestCase.st,v 1.89 2012-11-07 23:04:08 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestCase.st,v 1.88 2012-11-05 21:04:14 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestCase.st,v 1.89 2012-11-07 23:04:08 cg Exp $'
 !
 
 version_SVN