TestResource.st
author Claus Gittinger <cg@exept.de>
Tue, 27 May 2008 23:02:05 +0200
changeset 180 4b3b81b30817
parent 103 ad6897ce99e0
child 217 2033d47baf43
permissions -rw-r--r--
*** empty log message ***

"{ Package: 'stx:goodies/sunit' }"

Object subclass:#TestResource
	instanceVariableNames:'name description'
	classVariableNames:''
	poolDictionaries:''
	category:'SUnit-Base'
!

TestResource class instanceVariableNames:'current'

"
 No other class instance variables are inherited by this class.
"
!


!TestResource class methodsFor:'accessing'!

current

	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] ensure: [
			current := nil]]
			
!

signalInitializationError
	^TestResult signalErrorWith: 'Resource ' , self name , ' could not be initialized'
			
! !

!TestResource class methodsFor:'testing'!

isAbstract
        "Override to true if a TestResource subclass is Abstract and should not have
        TestCase instances built from it"

        ^ self == TestResource
!

isAvailable
	^self current notNil and: [self current isAvailable]
			
!

isUnavailable

	^self isAvailable not
			
! !

!TestResource methodsFor:'accessing'!

description

	description isNil
		ifTrue: [^''].

	^description
			
!

description: aString

	description := aString
			
!

name

	name isNil
		ifTrue: [^self printString].

	^name
			
!

name: aString

	name := aString
			
!

resources
	^self class resources
			
! !

!TestResource methodsFor:'init / release'!

initialize
	self setUp

			
! !

!TestResource methodsFor:'printing'!

printOn: aStream

	aStream nextPutAll: self class printString
			
! !

!TestResource methodsFor:'running'!

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"
	
	^true
			
!

isUnavailable
	"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.5 2008-05-27 21:02:05 cg Exp $'
! !