preparations for skipping tests;
authorClaus Gittinger <cg@exept.de>
Mon, 05 Nov 2012 22:03:08 +0100
changeset 487 52803f8a7029
parent 486 80dd1d67097b
child 488 53045c5fc90d
preparations for skipping tests; removed uses of symbols to avoid typing errors.
TestResult.st
--- a/TestResult.st	Fri Oct 26 00:23:21 2012 +0200
+++ b/TestResult.st	Mon Nov 05 22:03:08 2012 +0100
@@ -1,7 +1,7 @@
 "{ Package: 'stx:goodies/sunit' }"
 
 Object subclass:#TestResult
-	instanceVariableNames:'name timestamp failures errors passed outcome'
+	instanceVariableNames:'name timestamp failures errors passed skipped outcome'
 	classVariableNames:'DefaultClass'
 	poolDictionaries:''
 	category:'SUnit-Base'
@@ -54,6 +54,30 @@
     "Created: / 16-08-2011 / 15:02:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!TestResult class methodsFor:'constants'!
+
+stateError
+    ^ #error
+!
+
+stateFail
+    "this symbl used to freak around everywhere in the code;
+     and I was never sure if #fail or #failed is to be used."
+
+    ^ #fail
+!
+
+statePass
+    "this symbl used to freak around everywhere in the code;
+     and I was never sure if #pass or #passed is to be used."
+
+    ^ #pass
+!
+
+stateSkip
+    ^ #skip
+! !
+
 !TestResult class methodsFor:'exceptions'!
 
 error
@@ -154,7 +178,10 @@
 !
 
 failures
-        "We use a Set, not an OrderedCollection as #errors and #passed do, because a resumable test failure in a loop can raise many failures against the same test.  In current Sunit UIs, this could result in bizarre test count reporting (-27 tests run, and suchlike).  This will be reviewed."
+    "We use a Set, not an OrderedCollection as #errors and #passed do, 
+     because a resumable test failure in a loop can raise many failures against the same test.  
+     In current Sunit UIs, this could result in bizarre test count reporting (-27 tests run, and suchlike).  
+     This will be reviewed."
 
     failures isNil ifTrue: [^OrderedCollection new].
     ^failures collect:[:each|each testCase]
@@ -171,18 +198,16 @@
 !
 
 outcomes
+    |all|
 
-    ^OrderedCollection new
-        addAll: failures;
-        addAll: errors;
-        addAll: passed;
-        yourself
-
-    "Created: / 20-08-2011 / 14:00:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    all := OrderedCollection new.
+    self outcomesDo:[:each | all add:each].
+    ^ all.
 !
 
 outcomesDo: aBlock
 
+    skipped notNil ifTrue:[skipped do: aBlock].
     failures notNil ifTrue:[failures do: aBlock].
     errors notNil ifTrue:[errors do: aBlock].
     passed notNil ifTrue:[passed do: aBlock].
@@ -223,6 +248,26 @@
 	^self passedCount + self failureCount + self errorCount
 !
 
+skipped
+        skipped isNil ifTrue: [
+            "/ cg: exposed and added to (see TestRunnerEmbedded>>debug)
+            skipped := OrderedCollection new.
+            ^ skipped.
+        ].
+        ^skipped collect:[:each|each testCase]
+!
+
+skippedCount
+
+        ^self skippedOutcomes size
+!
+
+skippedOutcomes
+
+    skipped isNil ifTrue: [skipped := OrderedCollection new].
+    ^skipped
+!
+
 startTime:aTimestamp
     "sets the overall (suite) start time"
 
@@ -234,6 +279,7 @@
 
         ^(OrderedCollection new: self runCount)
                 addAll: self passedOutcomes;
+                addAll: self skippedOutcomes;
                 addAll: self errorOutcomes;
                 addAll: self failureOutcomes;
                 yourself
@@ -243,11 +289,12 @@
 
 tests
 
-	^(OrderedCollection new: self runCount)
-		addAll: self passed;
-		addAll: self errors;
-		addAll: self failures;
-		yourself
+        ^(OrderedCollection new: self runCount)
+                addAll: self passed;
+                addAll: self skipped;
+                addAll: self errors;
+                addAll: self failures;
+                yourself
 !
 
 timestamp
@@ -304,13 +351,20 @@
 
 addPass:testCase 
 
-    outcome result: #pass.
+    outcome result: (TestResult statePass).
     outcome remember.
     ^ self passedOutcomes add: outcome
 
     "Modified: / 20-08-2011 / 12:44:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+addSkipped:testCase 
+
+    outcome result: #skipped.
+    outcome remember.
+    ^ self skippedOutcomes add: outcome
+!
+
 remove: aTestCase
     "Removes an outcome for given testcase, if any.
     Use with care."
@@ -326,6 +380,7 @@
         ].
     ].
 
+    remover value: skipped.
     remover value: errors.
     remover value: failures.
     remover value: passed.
@@ -380,18 +435,20 @@
 
 printOn: aStream
 
-	aStream
-		nextPutAll: self runCount printString;
-		nextPutAll: ' run, ';
-		nextPutAll: self correctCount printString;
-		nextPutAll: ' passed, ';
-		nextPutAll: self failureCount printString;
-		nextPutAll: ' failed, ';
-		nextPutAll: self errorCount printString;
-		nextPutAll: ' error'.
+        aStream
+                nextPutAll: self runCount printString;
+                nextPutAll: ' run, ';
+                nextPutAll: self passedCount printString;
+                nextPutAll: ' passed, ';
+                nextPutAll: self skippedCount printString;
+                nextPutAll: ' skipped, ';
+                nextPutAll: self failureCount printString;
+                nextPutAll: ' failed, ';
+                nextPutAll: self errorCount printString;
+                nextPutAll: ' error'.
 
-	self errorCount ~= 1
-		ifTrue: [aStream nextPut: $s]
+        self errorCount ~= 1
+                ifTrue: [aStream nextPut: $s]
 ! !
 
 !TestResult methodsFor:'running'!
@@ -493,11 +550,11 @@
 !TestResult class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResult.st,v 1.45 2012-10-24 22:42:37 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResult.st,v 1.46 2012-11-05 21:03:08 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResult.st,v 1.45 2012-10-24 22:42:37 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResult.st,v 1.46 2012-11-05 21:03:08 cg Exp $'
 !
 
 version_SVN