"{ Package: 'stx:goodies/sunit' }"
TestCase subclass:#SUnitTest
instanceVariableNames:'hasRun hasSetup hasRanOnce'
classVariableNames:''
poolDictionaries:''
category:'SUnit-Tests'
!
!SUnitTest class methodsFor:'documentation'!
description
^ 'Tests SUnit itself
Two tests should fail.'
! !
!SUnitTest methodsFor:'Accessing'!
hasRun
^hasRun
!
hasSetup
^hasSetup
! !
!SUnitTest methodsFor:'Private'!
error
3 zork
"Modified: / 21.6.2000 / 10:22:18 / Sames"
!
fail
self assert: false
!
noop
!
setRun
hasRun := true
! !
!SUnitTest methodsFor:'Running'!
setUp
hasSetup := true
! !
!SUnitTest methodsFor:'Testing'!
testAssert
self assert: true.
self deny: false
!
testDebugUI
"This should break"
3 zork
"Modified: / 21.6.2000 / 10:22:50 / Sames"
!
testDefects
| result suite error failure |
suite := TestSuite new.
suite addTest: (error := self class selector: #error).
suite addTest: (failure := self class selector: #fail).
result := suite run.
self assert: result defects asArray = (Array with: error with: failure)
"Modified: / 21.6.2000 / 10:23:04 / Sames"
!
testDialectLocalizedException
self should: [TestResult signalFailureWith: 'Foo'] raise: TestResult failure.
self should: [TestResult signalErrorWith: 'Foo'] raise: TestResult error.
self shouldnt: [TestResult signalErrorWith: 'Foo'] raise: TestResult failure.
"Modified: / 21.6.2000 / 10:23:20 / Sames"
!
testError
| case result |
case := self class selector: #error.
result := case run.
self assert: result correctCount = 0.
self assert: result failureCount = 0.
self assert: result runCount = 1.
self assert: result errorCount = 1
!
testException
self should: [self error: 'foo'] raise: TestResult error
"Modified: / 21.6.2000 / 10:23:39 / Sames"
!
testFail
| case result |
case := self class selector: #fail.
result := case run.
self assert: result correctCount = 0.
self assert: result failureCount = 1.
self assert: result runCount = 1
!
testFailureDebugUI
"This should fail !!"
self fail
!
testIsNotRerunOnDebug
| case |
case := self class selector: #testRanOnlyOnce.
case run.
case debug
!
testRan
| case |
case := self class selector: #setRun.
case run.
self assert: case hasSetup.
self assert: case hasRun
!
testRanOnlyOnce
self assert: hasRanOnce ~= true.
hasRanOnce := true.
!
testResult
| case result |
case := self class selector: #noop.
result := case run.
self assert: result runCount = 1.
self assert: result correctCount = 1
!
testRunning
(SUnitDelay forSeconds: 2) wait
"Modified: / 21.6.2000 / 10:24:41 / Sames"
!
testShould
self should: [true].
self shouldnt: [false]
!
testSuite
| suite result |
suite := TestSuite new.
suite addTest: (self class selector: #noop).
suite addTest: (self class selector: #fail).
result := suite run.
self assert: result runCount = 2.
self assert: result correctCount = 1.
self assert: result failureCount = 1
! !
!SUnitTest class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/goodies/sunit/SUnitTest.st,v 1.4 2000-12-10 13:22:06 cg Exp $'
! !