TestResult.st
author Claus Gittinger <cg@exept.de>
Tue, 04 Sep 2001 21:03:35 +0200
changeset 33 1a5d44e6c9c5
parent 32 77f76ea3a7ef
child 47 7ea89e89bad3
permissions -rw-r--r--
*** empty log message ***

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

Object subclass:#TestResult
	instanceVariableNames:'runCount failures errors'
	classVariableNames:''
	poolDictionaries:''
	category:'SUnit-Base'
!


!TestResult class methodsFor:'Exceptions'!

error
       ^self exError

    "Modified: / 21.6.2000 / 10:07:16 / Sames"
!

exError
	"Change for Dialect"
	^Error

    "Modified: / 21.6.2000 / 10:10:45 / Sames"
!

failure
       ^TestFailure

    "Modified: / 21.6.2000 / 10:07:03 / Sames"
!

signalErrorWith: aString 
        self error raiseErrorString: aString

    "Modified: / 21.6.2000 / 10:11:07 / Sames"
!

signalFailureWith: aString 
        self failure raiseErrorString: aString

    "Modified: / 21.6.2000 / 10:11:20 / Sames"
! !

!TestResult class methodsFor:'Init / Release'!

new
	^super new initialize

    "Modified: / 21.6.2000 / 10:11:50 / Sames"
! !

!TestResult methodsFor:'Accessing'!

correctCount
	^self runCount - self failureCount - self errorCount

    "Modified: / 21.6.2000 / 10:07:48 / Sames"
!

defects
	^self errors, self failures

    "Modified: / 21.6.2000 / 10:07:56 / Sames"
!

errorCount
	^self errors size
!

errors
	errors isNil ifTrue: [errors := OrderedCollection new].
	^errors
!

failureCount
	^self failures size

    "Modified: / 21.6.2000 / 10:08:34 / Sames"
!

failures
	failures isNil ifTrue: [failures := OrderedCollection new].
	^failures
!

runCount
	^runCount
! !

!TestResult methodsFor:'Init / Release'!

initialize
	runCount := 0
! !

!TestResult methodsFor:'Printing'!

printOn: aStream
	aStream
		nextPutAll: self runCount printString;
		nextPutAll: ' run, ';
		nextPutAll: self failureCount printString;
		nextPutAll: ' failed, ';
		nextPutAll: self errorCount printString;
		nextPutAll:' error'.
	self errorCount ~= 1
		ifTrue: [aStream nextPut: $s].

    "Created: / 21.6.2000 / 10:09:12 / Sames"
! !

!TestResult methodsFor:'Running'!

runCase: aTestCase
        runCount := runCount + 1.
        [[aTestCase runCase] 
                on: self class failure
                do: 
                        [:signal | 
                        self failures add: aTestCase.
                        signal returnWith: nil]]
                        on: self class error
                        do:
                                [:signal |
                                self errors add: aTestCase.
                                signal returnWith: nil]

    "Modified: / 21.6.2000 / 10:10:06 / Sames"
! !

!TestResult methodsFor:'Testing'!

hasPassed
	^self runCount = self correctCount
!

isFailure: aTestCase
	^self failures includes: aTestCase
! !

!TestResult class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResult.st,v 1.6 2001-09-04 19:03:35 cg Exp $'
! !