--- a/TestCase.st Tue Aug 09 17:08:35 2011 +0200
+++ b/TestCase.st Tue Aug 09 23:56:13 2011 +0200
@@ -61,15 +61,18 @@
!TestCase class methodsFor:'accessing'!
allTestSelectors
- | answer pivotClass lookupRoot |
- answer := Set withAll: self testSelectors.
- self shouldInheritSelectors ifTrue:
- [pivotClass := self.
- lookupRoot := self lookupHierarchyRoot.
- [pivotClass == lookupRoot] whileFalse:
- [pivotClass := pivotClass superclass.
- answer addAll: pivotClass testSelectors]].
- ^answer asSortedCollection asOrderedCollection
+ | answer pivotClass lookupRoot |
+
+ answer := Set withAll: self testSelectors.
+ self shouldInheritSelectors ifTrue:[
+ pivotClass := self superclass.
+ lookupRoot := self lookupHierarchyRoot.
+ [pivotClass == lookupRoot] whileFalse:[
+ pivotClass := pivotClass superclass.
+ answer addAll: pivotClass testSelectors
+ ]
+ ].
+ ^answer asSortedCollection asOrderedCollection
!
forgetLastTestRunResult
@@ -574,14 +577,7 @@
!
performTest
- startTime := Timestamp now.
- [
- self perform: testSelector sunitAsSymbol
- ] ensure:[
- endTime := Timestamp now
- ].
-
- "Modified: / 30-07-2011 / 10:08:55 / cg"
+ self perform: testSelector sunitAsSymbol
!
setTestSelector: aSymbol
@@ -798,15 +794,24 @@
!
runCase
- self resources do: [:each | each availableFor: self].
- [
- self setUp.
- self performTest
- ] sunitEnsure: [
- self tearDown
- ]
+ self resources do: [:each | each availableFor: self].
+
+ "modified to remember start- and end time, and also redirect
+ std-output + Transcript to a collecting stream. The output is
+ later avaliable to the reporter."
- "Modified (format): / 05-07-2011 / 18:21:33 / cg"
+ [
+ self setUp.
+ startTime := Timestamp now.
+ self withStandardOutputAndTranscriptRedirectedDo:[
+ self performTest.
+ ].
+ ] sunitEnsure: [
+ endTime := Timestamp now.
+ self tearDown
+ ]
+
+ "Modified (comment): / 09-08-2011 / 23:18:49 / cg"
!
runCaseAsFailure
@@ -828,16 +833,37 @@
!
tearDown
+!
+
+withStandardOutputAndTranscriptRedirectedDo:aBlock
+ |result savedStdout savedTranscript collector|
+
+ ((Smalltalk respondsTo:#isSmalltalkX) and:[Smalltalk isSmalltalkX]) ifTrue:[
+ savedStdout := Stdout.
+ savedTranscript := Transcript.
+ collector := WriteStream on:(String new:100).
+ [
+ Stdout := Transcript := collector.
+ result := aBlock value.
+ ] ensure:[
+ Stdout := savedStdout.
+ Transcript := savedTranscript.
+ ].
+ ^ result.
+ ].
+
+ "/ add other dialects here...
+ ^ aBlock value
! !
!TestCase class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/goodies/sunit/TestCase.st,v 1.72 2011-08-09 08:50:04 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/goodies/sunit/TestCase.st,v 1.73 2011-08-09 21:56:13 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/goodies/sunit/TestCase.st,v 1.72 2011-08-09 08:50:04 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/goodies/sunit/TestCase.st,v 1.73 2011-08-09 21:56:13 cg Exp $'
!
version_SVN