--- a/TestResource.st Fri Aug 29 20:36:18 2003 +0200
+++ b/TestResource.st Fri Sep 26 17:53:45 2003 +0200
@@ -18,74 +18,117 @@
!TestResource class methodsFor:'accessing'!
current
- current isNil ifTrue: [current := self new].
+
+ current isNil
+ ifTrue: [current := self new].
+
^current
+
!
current: aTestResource
+
current := aTestResource
+
+!
+
+resources
+ ^#()
+
! !
!TestResource class methodsFor:'creation'!
new
+
^super new initialize
+
!
reset
- current notNil ifTrue:
- [current tearDown.
- current := nil]
- "self withAllSubclassesDo:[:each| each reset]"
+ current notNil ifTrue: [
+ [current tearDown] ensure: [
+ current := nil]]
+
+!
+
+signalInitializationError
+ ^TestResult signalErrorWith: 'Resource ' , self name , ' could not be initialized'
+
! !
!TestResource class methodsFor:'testing'!
isAbstract
- "Override to true if a TestCase subclass is Abstract and should not have
- TestCase instances built from it"
- ^self name = #TestResource
+ "Override to true if a TestResource subclass is Abstract and should not have
+ TestCase instances built from it"
+
+ ^ self name == #TestResource
!
isAvailable
- ^self current notNil
+ ^self current notNil and: [self current isAvailable]
+
!
isUnavailable
+
^self isAvailable not
+
! !
!TestResource methodsFor:'accessing'!
description
- description isNil ifTrue: [^''].
+
+ description isNil
+ ifTrue: [^''].
+
^description
+
!
description: aString
+
description := aString
+
!
name
- name isNil ifTrue: [^self printString].
+
+ name isNil
+ ifTrue: [^self printString].
+
^name
+
!
name: aString
+
name := aString
+
+!
+
+resources
+ ^self class resources
+
! !
!TestResource methodsFor:'init / release'!
initialize
- self setUp
+ self setUp
+
+
! !
!TestResource methodsFor:'printing'!
printOn: aStream
+
aStream nextPutAll: self class printString
+
! !
!TestResource methodsFor:'running'!
@@ -93,27 +136,40 @@
setUp
"Does nothing. Subclasses should override this
to initialize their resource"
+
+!
+
+signalInitializationError
+ ^self class signalInitializationError
+
!
tearDown
"Does nothing. Subclasses should override this
to tear down their resource"
+
! !
!TestResource methodsFor:'testing'!
isAvailable
- "override to provide information on the readiness of the resource"
+ "override to provide information on the
+ readiness of the resource"
+
^true
+
!
isUnavailable
- "override to provide information on the readiness of the resource"
+ "override to provide information on the
+ readiness of the resource"
+
^self isAvailable not
+
! !
!TestResource class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResource.st,v 1.3 2002-06-19 12:21:01 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResource.st,v 1.4 2003-09-26 15:53:19 stefan Exp $'
! !