TestAsserter.st
author Claus Gittinger <cg@exept.de>
Sun, 01 Jul 2018 12:52:19 +0200
changeset 719 2c96860ad5cb
parent 718 b37f66696d9b
child 721 c11e3a43a1b4
permissions -rw-r--r--
#FEATURE by cg class: TestCase::Should class definition added: #assertSelector #beInstanceOf: #equal: #not #raise: changed: #be:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
708
35643bf43d6a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
     1
"{ Encoding: utf8 }"
35643bf43d6a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
     2
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"{ Package: 'stx:goodies/sunit' }"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
     5
"{ NameSpace: Smalltalk }"
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
     6
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
Object subclass:#TestAsserter
376
3fff80e1b3be removed leftover rubbish
Claus Gittinger <cg@exept.de>
parents: 333
diff changeset
     8
	instanceVariableNames:''
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
	classVariableNames:''
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
	poolDictionaries:''
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
	category:'SUnit-Base'
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
TestAsserter comment:''
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
!TestAsserter class methodsFor:'asserting'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
assert: aBoolean description: aString
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    21
        "Minimal clone of the instance-side assert protocol so that class-side methods can use it."
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    23
        aBoolean ifFalse: [
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    24
            self logFailure: aString.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    25
            TestResult failure sunitSignalWith: aString
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    26
        ].
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    27
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    28
    "Modified (format): / 13-07-2017 / 15:03:51 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
!TestAsserter class methodsFor:'logging'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
failureLog
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
	^SUnitNameResolver defaultLogDevice
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
isLogging
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
	"By default, we're not logging failures. Override in subclasses as desired."
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
	^false
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
logFailure: aString
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
	self isLogging ifTrue:
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
		[self failureLog cr; nextPutAll: aString; flush].
551
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
    46
!
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
    47
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
    48
logSkipped: aString
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
    49
        self isLogging ifTrue:
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
    50
                [self failureLog cr; nextPutAll: aString; flush].
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    53
!TestAsserter class methodsFor:'private'!
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    54
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    55
comparingCollectionBetween: left and: right
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    56
    "helper to generate a nice description, if 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    57
     a collection is not the expected one."
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    58
     
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    59
    | additionalLeft additionalRight sortBlock|
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    60
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    61
    "use a very slow sort block"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    62
    sortBlock := [ :a :b | a asString <= b asString ].
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    63
    additionalLeft := (left difference: right) sorted: sortBlock.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    64
    additionalRight := (right difference: left) sorted: sortBlock. 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    65
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    66
    ^ String 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    67
        streamContents: [:stream |
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    68
            stream
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    69
                nextPutAll: 'Given Collections do not match.'; lf;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    70
                tab; nextPutAll: 'Got left := '; print: left; nextPut: $.; lf;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    71
                nextPutAll: ' instead of '; lf;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    72
                tab; nextPutAll: 'right :='; print: right; nextPut: $.; lf.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    73
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    74
            left size = right size ifFalse: [ 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    75
                stream 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    76
                    nextPutAll: 'Collection size does not match: left='; 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    77
                    print: left size;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    78
                    nextPutAll: ' vs. right=';
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    79
                    print: right size; lf 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    80
            ].
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    81
            additionalLeft notEmpty ifTrue:[
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    82
                  stream
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    83
                      nextPutAll:'Got ';
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    84
                      print:additionalLeft size;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    85
                      nextPutAll:' additional element(s) in the left collection: ';
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    86
                      tab;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    87
                      print:additionalLeft
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    88
            ].
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    89
            additionalRight notEmpty ifTrue:[
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    90
                  stream
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    91
                      nextPutAll:'Got ';
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    92
                      print:additionalRight size;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    93
                      nextPutAll:' additional element(s) in the right collection: ';
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    94
                      tab;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    95
                      print:additionalRight
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    96
            ]
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    97
        ]
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    98
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    99
    "
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   100
     self basicNew comparingCollectionBetween:#(1 2 3) and:#(1 2 3 4)
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   101
    "
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   102
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   103
    "Modified: / 13-07-2017 / 14:13:15 / cg"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   104
! !
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   105
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
!TestAsserter methodsFor:'asserting'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   108
assert: aBooleanOrBlock
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   109
    "fail the testcase if aBooleanOrBlock evaluates to false"
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   110
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   113
    aBooleanOrBlock value ifFalse:[
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   114
        self logFailure: 'Assertion failed'.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   115
        TestResult failure sunitSignalWith: 'Assertion failed'
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   116
    ].
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   118
    "Modified: / 05-12-2009 / 18:14:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   119
    "Modified: / 13-07-2017 / 13:50:13 / cg"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   120
    "Modified (comment): / 13-07-2017 / 15:05:33 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   123
assert:aBooleanOrBlock description:aString
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   124
    "fail the testCase if aBooleanOrBlock evaluates to false, 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   125
     and report aStringOrBlock's value as failure-description."
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
708
35643bf43d6a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   127
    <resource: #skipInDebuggersWalkBack>
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
692
781228855c60 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 687
diff changeset
   129
    ^ self assert:aBooleanOrBlock description:aString resumable: false.
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   130
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   131
    "Modified: / 11-09-2010 / 15:34:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
692
781228855c60 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 687
diff changeset
   132
    "Modified (format): / 09-11-2017 / 10:03:58 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   135
assert:aBooleanOrBlock description:aStringOrBlock resumable:resumableBoolean
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   136
    "fail the testCase if aBooleanOrBlock evaluates to false, 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   137
     and report aStringOrBlock's value as failure-description.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   138
     If resumableBoolean is true, the test can be resumed in the debugger (if it was started by 'Debug')"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   142
    | exception |
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   143
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   144
    aBooleanOrBlock value ifFalse:[
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   145
        |string|
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   147
        string := aStringOrBlock value.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   148
        self logFailure: string.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   149
        exception := resumableBoolean
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   150
                        ifTrue: [TestResult resumableFailure]
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   151
                        ifFalse: [TestResult failure].
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   152
        exception sunitSignalWith: string
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   153
    ].
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   154
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   155
    "Modified: / 05-12-2009 / 18:15:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   156
    "Modified: / 13-07-2017 / 13:49:38 / cg"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   157
    "Modified (comment): / 13-07-2017 / 15:07:33 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   160
deny: aBooleanOrBlock
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   161
    "fail the testcase if aBooleanOrBlock evaluates to true"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
    <resource: #skipInDebuggersWalkBack>
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   164
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   165
    self assert:(aBooleanOrBlock value not).
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   167
    "Modified: / 05-12-2009 / 18:16:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   168
    "Modified (comment): / 13-07-2017 / 15:06:17 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   171
deny: aBooleanOrBlock description: aString
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   172
    "fail the testCase if aBooleanOrBlock evaluates to true, 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   173
     and report aStringOrBlock's value as failure-description."
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   177
    self assert:(aBooleanOrBlock value not) description:aString.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   178
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   179
    "Modified: / 05-12-2009 / 18:17:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   180
    "Modified (comment): / 13-07-2017 / 15:06:30 / cg"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   181
!
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   182
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   183
deny:aBooleanOrBlock description:aString resumable:resumableBoolean
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   184
    "fail the testCase if aBooleanOrBlock evaluates to true, 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   185
     and report aStringOrBlock's value as failure-description.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   186
     If resumableBoolean is true, the test can be resumed in the debugger (if it was started by 'Debug')"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   187
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   188
    <resource: #skipInDebuggersWalkBack>
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   189
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   190
    self assert:(aBooleanOrBlock value not) description:aString resumable:resumableBoolean.
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
    "Modified: / 05-12-2009 / 18:17:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   193
    "Modified (comment): / 13-07-2017 / 15:07:38 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
should: aBlock raise: anExceptionalEvent
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   197
    "during the execution of aBlock, the anExceptionalEvent should be raised"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
    self assert: (self executeShould: aBlock inScopeOf: anExceptionalEvent).
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    "Modified: / 05-12-2009 / 18:18:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
should: aBlock raise: anExceptionalEvent description: aString
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   207
    "during the execution of aBlock, the anExceptionalEvent should be raised.
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   208
     If not, report aString as failure-description."
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    self
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   213
        assert: (self executeShould: aBlock inScopeOf: anExceptionalEvent)
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   214
        description: aString.
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
    "Modified: / 05-12-2009 / 18:18:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
should: aBlock raise: anExceptionalEvent suchThat: condBlock
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   220
    "during the execution of aBlock, the anExceptionalEvent should be raised,
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   221
     and condBlock should return true on the exception instance"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
    self assert: (self executeShould: aBlock inScopeOf: anExceptionalEvent suchThat: condBlock).
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
    "Created: / 05-05-2011 / 20:14:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
should: aBlock raise: anExceptionalEvent suchThat: condBlock description: description
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   231
    "during the execution of aBlock, the anExceptionalEvent should be raised,
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   232
     and condBlock should return true on the exception instance.
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   233
     If not, report aString as failure-description."
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
    self assert: (self executeShould: aBlock inScopeOf: anExceptionalEvent suchThat: condBlock)
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   238
         description: description
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
    "Created: / 05-05-2011 / 20:14:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   243
should: aBlock raise: anExceptionalEvent whoseDescriptionIncludes: aStringFragment
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   244
    "during the execution of aBlock, the anExceptionalEvent should be raised,
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   245
     and aStringFragment should be contained in the exception-instances description."
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   246
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   247
    <resource: #skipInDebuggersWalkBack>
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   248
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   249
    ^ self should: aBlock 
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   250
           raise: anExceptionalEvent
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   251
           suchThat:[:ex | ex description includesString: aStringFragment]
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   252
!
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   253
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   254
should:aBlock raise:anExceptionalEvent whoseDescriptionIncludes:aStringFragment description:aString
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   255
    "during the execution of aBlock, the anExceptionalEvent should be raised,
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   256
     and aStringFragment should be contained in the exception-instances description.
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   257
     If not, report aString as failure-description."
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   258
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   259
    <resource: #skipInDebuggersWalkBack>
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   260
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   261
    ^ self should: aBlock 
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   262
           raise: anExceptionalEvent
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   263
           suchThat:[:ex | ex description includesString: aStringFragment]
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   264
           description: aString.
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   265
!
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   266
718
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   267
should:aBlock raise:anExceptionalEvent withExceptionDo:exCheckAction
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   268
    "during the execution of aBlock, the anExceptionalEvent should be raised,
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   269
     then exCheckAction is evaluated on the exception (which usually includes more checks).
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   270
     If not, report aString as failure-description."
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   271
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   272
    <resource: #skipInDebuggersWalkBack>
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   273
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   274
    ^ self should: aBlock 
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   275
           raise: anExceptionalEvent
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   276
           suchThat:[:ex | exCheckAction value:ex. true]
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   277
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   278
    "should fail:
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   279
    
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   280
         self new
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   281
            should:[ 1 / Float zero]
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   282
            raise:ZeroDivide
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   283
            withExceptionDo:[:ex |
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   284
                ex description should equal:'hello world'
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   285
            ].
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   286
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   287
     should fail:   
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   288
         self new
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   289
            should:[ 1 / Float zero]
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   290
            raise:ZeroDivide
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   291
            withExceptionDo:[:ex |
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   292
                ex description should equal:'hello world'
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   293
            ].
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   294
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   295
     should pass:   
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   296
         self new
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   297
            should:[ 1 / Float zero]
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   298
            raise:ZeroDivide
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   299
            withExceptionDo:[:ex |
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   300
                ex description should equal:'hello world'
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   301
            ].
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   302
    "
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   303
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   304
    "Created: / 01-07-2018 / 12:18:18 / Claus Gittinger"
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   305
!
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   306
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
shouldnt: aBlock raise: anExceptionalEvent
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   308
    "during the execution of aBlock, the anExceptionalEvent should NOT be raised"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
    self
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   313
        assert: (self executeShould: aBlock inScopeOf: anExceptionalEvent) not.
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
    "Modified: / 05-12-2009 / 18:18:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
shouldnt: aBlock raise: anExceptionalEvent description: aString
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   319
    "during the execution of aBlock, the anExceptionalEvent should NOT be raised.
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   320
     If not, report aString as failure-description."
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
    self
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   325
        assert: (self executeShould: aBlock inScopeOf: anExceptionalEvent) not
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   326
        description: aString.
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
    "Modified: / 05-12-2009 / 18:18:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
551
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   329
!
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   330
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   331
skip
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   332
    "skip this test"
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   333
    
650
20c408a44d5d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
   334
    self skipIf:true description:'Test Skipped'.
649
a69fdedffe06 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   335
!
a69fdedffe06 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   336
674
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   337
skip:messageString
649
a69fdedffe06 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   338
    "skip this test"
a69fdedffe06 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   339
    
674
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   340
    self skipIf:true description:messageString
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   341
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   342
    "Modified (format): / 12-02-2017 / 22:44:11 / cg"
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   343
!
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   344
674
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   345
skipIf:aCondition description:messageString
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   346
    "skip this test, if some condition is met"
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   347
    
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   348
    aCondition value ifTrue: [
674
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   349
        self logSkipped: 'Skipped - ',messageString.
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   350
        TestResult skipped sunitSignalWith: messageString
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   351
    ].
674
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   352
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   353
    "Modified (format): / 12-02-2017 / 22:44:17 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
!TestAsserter methodsFor:'convenience'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   358
assert:anObject equals:anotherObject
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   359
    ^ self 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   360
        assert: anObject = anotherObject
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   361
        description: [ anObject printString, ' is not equal to ', anotherObject printString ].
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   362
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   363
    "Modified: / 13-07-2017 / 15:12:26 / cg"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   364
!
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   365
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   366
assertCollection:actual equals:expected
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   367
    "specialized test method that generates a proper error message for collection"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   368
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   369
    ^ self 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   370
        assert:(expected = actual)
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   371
        description:[ self class comparingCollectionBetween:actual and:expected ]
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   372
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   373
    "
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   374
     self basicNew assertCollection:#(1 2 3) equals:#(1 2 3)
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   375
     self basicNew assertCollection:#(1 2 3) equals:#(1 2 3 4)
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   376
    "
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   377
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   378
    "Created: / 13-07-2017 / 13:46:51 / cg"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   379
    "Modified (comment): / 13-07-2017 / 15:03:28 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
!TestAsserter methodsFor:'logging'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
logFailure: aString
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
	self class logFailure: aString.
551
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   386
!
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   387
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   388
logSkipped: aString
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   389
        self class logSkipped: aString.
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
!TestAsserter methodsFor:'private'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
executeShould: execBlock inScopeOf: exceptionalEvent
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
    ^ self
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
	executeShould: execBlock
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
	inScopeOf: exceptionalEvent
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
	suchThat: [:ex | true ]
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
    "Modified: / 05-05-2011 / 20:23:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
executeShould: execBlock inScopeOf: exceptionalEvent suchThat: conditionBlock
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
	^[execBlock value.
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
	false]
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
		sunitOn: exceptionalEvent
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
		do:
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
		    [:ex |
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
		    ex sunitExitWith:(conditionBlock value: ex)]
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
    "Created: / 05-05-2011 / 20:08:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
!TestAsserter class methodsFor:'documentation'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
286
01b3ae052203 changed: #executionTime
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   419
version
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   420
    ^ '$Header$'
286
01b3ae052203 changed: #executionTime
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   421
!
01b3ae052203 changed: #executionTime
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   422
223
354de0061492 initial checkin
Claus Gittinger <cg@exept.de>
parents: 222
diff changeset
   423
version_CVS
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   424
    ^ '$Header$'
223
354de0061492 initial checkin
Claus Gittinger <cg@exept.de>
parents: 222
diff changeset
   425
!
354de0061492 initial checkin
Claus Gittinger <cg@exept.de>
parents: 222
diff changeset
   426
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
version_SVN
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   428
    ^ '$Id$'
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
! !
551
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   430