--- a/TestSuite.st Fri Aug 29 20:36:18 2003 +0200
+++ b/TestSuite.st Fri Sep 26 17:53:45 2003 +0200
@@ -1,96 +1,104 @@
"{ Package: 'stx:goodies/sunit' }"
Object subclass:#TestSuite
- instanceVariableNames:'name tests resources'
+ instanceVariableNames:'tests resources name'
classVariableNames:''
poolDictionaries:''
category:'SUnit-Base'
!
+TestSuite comment:'This is a Composite of Tests, either TestCases or other TestSuites. The common protocol is #run: aTestResult and the dependencies protocol'
+!
-!TestSuite class methodsFor:'creation'!
+
+!TestSuite class methodsFor:'Creation'!
named: aString
- ^self new
- name: aString;
- yourself
+
+ ^self new
+ name: aString;
+ yourself
+
! !
!TestSuite methodsFor:'accessing'!
addTest: aTest
self tests add: aTest
+
!
addTests: aCollection
aCollection do: [:eachTest | self addTest: eachTest]
+
!
defaultResources
^self tests
inject: Set new
- into:
- [:coll :testCase |
+ into: [:coll :testCase |
coll
addAll: testCase resources;
yourself]
+
!
name
+
^ name ? 'a TestSuite'.
!
-name:aString
- name := aString
+name: aString
+
+ name := aString
+
!
resources
resources isNil ifTrue: [resources := self defaultResources].
^resources
+
!
resources: anObject
resources := anObject
+
!
tests
tests isNil ifTrue: [tests := OrderedCollection new].
^tests
+
! !
!TestSuite methodsFor:'dependencies'!
addDependentToHierachy: anObject
self addDependent: anObject.
- self tests do: [:each | each addDependentToHierachy: anObject]
-
- "Modified: / 21.6.2000 / 10:13:35 / Sames"
+ self tests do: [ :each | each addDependentToHierachy: anObject]
!
removeDependentFromHierachy: anObject
self removeDependent: anObject.
- self tests do: [:each | each removeDependentFromHierachy: anObject]
-
- "Modified: / 21.6.2000 / 10:13:27 / Sames"
+ self tests do: [ :each | each removeDependentFromHierachy: anObject]
! !
!TestSuite methodsFor:'running'!
run
| result |
+
+ self signalUnavailableResources.
+
result := TestResult new.
- self areAllResourcesAvailable ifFalse: [^TestResult signalErrorWith: 'Resource could not be initialized'].
[self run: result] ensure: [self resources do: [:each | each reset]].
^result
!
run: aResult
- self tests do:
- [:each |
+ self tests do: [:each |
self changed: each.
each run: aResult]
-
- "Modified: / 21.6.2000 / 10:14:01 / Sames"
!
run: aResult afterEachDo:block2
@@ -121,10 +129,19 @@
^self resources
inject: true
into: [:total :each | each isAvailable & total]
+!
+
+signalUnavailableResources
+
+ self resources do:[:res |
+ res isAvailable ifFalse:[
+ ^ res signalInitializationError
+ ]
+ ].
! !
!TestSuite class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/goodies/sunit/TestSuite.st,v 1.12 2002-12-10 09:53:11 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/goodies/sunit/TestSuite.st,v 1.13 2003-09-26 15:53:45 stefan Exp $'
! !