TestAsserter.st
author Claus Gittinger <cg@exept.de>
Wed, 29 May 2019 01:12:49 +0200
changeset 747 1dcb53cf964d
parent 729 5df0b62db3d7
permissions -rw-r--r--
#FEATURE by cg class: TestCase added: #invokeTestMethod changed: #performTest support timeout annotation
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
721
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
    20
assert: aBooleanOrBlock 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
721
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
    23
        aBooleanOrBlock value ifFalse: [
687
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"
721
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
    29
    "Modified: / 26-08-2018 / 18:06:18 / Claus Gittinger"
222
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
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
!TestAsserter class methodsFor:'logging'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
failureLog
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
	^SUnitNameResolver defaultLogDevice
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
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
isLogging
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
	"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
    40
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
	^false
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
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
logFailure: aString
729
5df0b62db3d7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    45
    self isLogging ifTrue:[
5df0b62db3d7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    46
        self failureLog cr; nextPutAll: aString; flush
5df0b62db3d7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    47
    ].
5df0b62db3d7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    48
5df0b62db3d7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    49
    "Modified (format): / 22-03-2019 / 12:48:35 / Claus Gittinger"
551
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
    50
!
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
    51
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
    52
logSkipped: aString
729
5df0b62db3d7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    53
    self isLogging ifTrue:[
5df0b62db3d7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    54
        self failureLog cr; nextPutAll: aString; flush
5df0b62db3d7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    55
    ].
5df0b62db3d7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    56
5df0b62db3d7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
    57
    "Modified (format): / 22-03-2019 / 12:47:01 / Claus Gittinger"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    60
!TestAsserter class methodsFor:'private'!
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    61
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    62
comparingCollectionBetween: left and: right
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    63
    "helper to generate a nice description, if 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    64
     a collection is not the expected one."
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
    | additionalLeft additionalRight sortBlock|
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    67
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    68
    "use a very slow sort block"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    69
    sortBlock := [ :a :b | a asString <= b asString ].
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    70
    additionalLeft := (left difference: right) sorted: sortBlock.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    71
    additionalRight := (right difference: left) sorted: sortBlock. 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    72
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    73
    ^ String 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    74
        streamContents: [:stream |
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: 'Given Collections do not match.'; lf;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    77
                tab; nextPutAll: 'Got left := '; print: left; nextPut: $.; lf;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    78
                nextPutAll: ' instead of '; lf;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    79
                tab; nextPutAll: 'right :='; print: right; nextPut: $.; 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
            left size = right size ifFalse: [ 
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: 'Collection size does not match: left='; 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    84
                    print: left size;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    85
                    nextPutAll: ' vs. right=';
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    86
                    print: right size; lf 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    87
            ].
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    88
            additionalLeft notEmpty ifTrue:[
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    89
                  stream
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    90
                      nextPutAll:'Got ';
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    91
                      print:additionalLeft size;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    92
                      nextPutAll:' additional element(s) in the left collection: ';
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    93
                      tab;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    94
                      print:additionalLeft
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    95
            ].
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    96
            additionalRight notEmpty ifTrue:[
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    97
                  stream
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    98
                      nextPutAll:'Got ';
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    99
                      print:additionalRight size;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   100
                      nextPutAll:' additional element(s) in the right collection: ';
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   101
                      tab;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   102
                      print:additionalRight
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   103
            ]
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
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   106
    "
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   107
     self basicNew comparingCollectionBetween:#(1 2 3) and:#(1 2 3 4)
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   108
    "
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   109
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   110
    "Modified: / 13-07-2017 / 14:13:15 / cg"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   111
! !
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   112
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
!TestAsserter methodsFor:'asserting'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   115
assert: aBooleanOrBlock
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   116
    "fail the testcase if aBooleanOrBlock evaluates to false"
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   117
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   120
    aBooleanOrBlock value ifFalse:[
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   121
        self logFailure: 'Assertion failed'.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   122
        TestResult failure sunitSignalWith: 'Assertion failed'
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   123
    ].
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   125
    "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
   126
    "Modified: / 13-07-2017 / 13:50:13 / cg"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   127
    "Modified (comment): / 13-07-2017 / 15:05:33 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   130
assert:aBooleanOrBlock description:aString
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   131
    "fail the testCase if aBooleanOrBlock evaluates to false, 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   132
     and report aStringOrBlock's value as failure-description."
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
708
35643bf43d6a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   134
    <resource: #skipInDebuggersWalkBack>
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
692
781228855c60 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 687
diff changeset
   136
    ^ self assert:aBooleanOrBlock description:aString resumable: false.
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   137
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   138
    "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
   139
    "Modified (format): / 09-11-2017 / 10:03:58 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
!
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
assert:aBooleanOrBlock description:aStringOrBlock resumable:resumableBoolean
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   143
    "fail the testCase if aBooleanOrBlock evaluates to false, 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   144
     and report aStringOrBlock's value as failure-description.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   145
     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
   146
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   149
    | exception |
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   150
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   151
    aBooleanOrBlock value ifFalse:[
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   152
        |string|
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   154
        string := aStringOrBlock value.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   155
        self logFailure: string.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   156
        exception := resumableBoolean
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   157
                        ifTrue: [TestResult resumableFailure]
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   158
                        ifFalse: [TestResult failure].
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   159
        exception sunitSignalWith: string
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   160
    ].
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   161
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   162
    "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
   163
    "Modified: / 13-07-2017 / 13:49:38 / cg"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   164
    "Modified (comment): / 13-07-2017 / 15:07:33 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
!
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
deny: aBooleanOrBlock
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   168
    "fail the testcase if aBooleanOrBlock evaluates to true"
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
    <resource: #skipInDebuggersWalkBack>
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   171
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   172
    self assert:(aBooleanOrBlock value not).
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   174
    "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
   175
    "Modified (comment): / 13-07-2017 / 15:06:17 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   178
deny: aBooleanOrBlock description: aString
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   179
    "fail the testCase if aBooleanOrBlock evaluates to true, 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   180
     and report aStringOrBlock's value as failure-description."
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   184
    self assert:(aBooleanOrBlock value not) description:aString.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   185
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   186
    "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
   187
    "Modified (comment): / 13-07-2017 / 15:06:30 / cg"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   188
!
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
deny:aBooleanOrBlock description:aString resumable:resumableBoolean
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   191
    "fail the testCase if aBooleanOrBlock evaluates to true, 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   192
     and report aStringOrBlock's value as failure-description.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   193
     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
   194
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   195
    <resource: #skipInDebuggersWalkBack>
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   196
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   197
    self assert:(aBooleanOrBlock value not) description:aString resumable:resumableBoolean.
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
    "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
   200
    "Modified (comment): / 13-07-2017 / 15:07:38 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
!
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
should: aBlock raise: anExceptionalEvent
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   204
    "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
   205
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
    self assert: (self executeShould: aBlock inScopeOf: anExceptionalEvent).
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
    "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
   211
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
should: aBlock raise: anExceptionalEvent description: aString
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   214
    "during the execution of aBlock, the anExceptionalEvent should be raised.
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   215
     If not, report aString as failure-description."
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
    <resource: #skipInDebuggersWalkBack>
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
    self
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   220
        assert: (self executeShould: aBlock inScopeOf: anExceptionalEvent)
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   221
        description: aString.
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
    "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
   224
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
should: aBlock raise: anExceptionalEvent suchThat: condBlock
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   227
    "during the execution of aBlock, the anExceptionalEvent should be raised,
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   228
     and condBlock should return true on the exception instance"
222
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
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
    self assert: (self executeShould: aBlock inScopeOf: anExceptionalEvent suchThat: condBlock).
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
    "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
   235
!
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
should: aBlock raise: anExceptionalEvent suchThat: condBlock description: description
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   238
    "during the execution of aBlock, the anExceptionalEvent should be raised,
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   239
     and condBlock should return true on the exception instance.
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   240
     If not, report aString as failure-description."
222
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
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
    self assert: (self executeShould: aBlock inScopeOf: anExceptionalEvent suchThat: condBlock)
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   245
         description: description
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
    "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
   248
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   250
should: aBlock raise: anExceptionalEvent whoseDescriptionIncludes: aStringFragment
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   251
    "during the execution of aBlock, the anExceptionalEvent should be raised,
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   252
     and aStringFragment should be contained in the exception-instances description."
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
    <resource: #skipInDebuggersWalkBack>
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   255
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   256
    ^ self should: aBlock 
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   257
           raise: anExceptionalEvent
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   258
           suchThat:[:ex | ex description includesString: aStringFragment]
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   259
!
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
should:aBlock raise:anExceptionalEvent whoseDescriptionIncludes:aStringFragment description:aString
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   262
    "during the execution of aBlock, the anExceptionalEvent should be raised,
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   263
     and aStringFragment should be contained in the exception-instances description.
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   264
     If not, report aString as failure-description."
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
    <resource: #skipInDebuggersWalkBack>
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   267
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   268
    ^ self should: aBlock 
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   269
           raise: anExceptionalEvent
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   270
           suchThat:[:ex | ex description includesString: aStringFragment]
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   271
           description: aString.
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   272
!
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   273
718
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   274
should:aBlock raise:anExceptionalEvent withExceptionDo:exCheckAction
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   275
    "during the execution of aBlock, the anExceptionalEvent should be raised,
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   276
     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
   277
     If not, report aString as failure-description."
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   278
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   279
    <resource: #skipInDebuggersWalkBack>
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   280
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   281
    ^ self should: aBlock 
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   282
           raise: anExceptionalEvent
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   283
           suchThat:[:ex | exCheckAction value:ex. true]
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   284
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   285
    "should fail:
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
         self new
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   288
            should:[ 1 / Float zero]
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   289
            raise:ZeroDivide
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   290
            withExceptionDo:[:ex |
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   291
                ex description should equal:'hello world'
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   292
            ].
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
     should fail:   
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   295
         self new
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   296
            should:[ 1 / Float zero]
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   297
            raise:ZeroDivide
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   298
            withExceptionDo:[:ex |
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   299
                ex description should equal:'hello world'
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   300
            ].
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
     should pass:   
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   303
         self new
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   304
            should:[ 1 / Float zero]
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   305
            raise:ZeroDivide
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   306
            withExceptionDo:[:ex |
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   307
                ex description should equal:'hello world'
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   308
            ].
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   309
    "
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   310
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   311
    "Created: / 01-07-2018 / 12:18:18 / Claus Gittinger"
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   312
!
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   313
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
shouldnt: aBlock raise: anExceptionalEvent
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   315
    "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
   316
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
    self
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   320
        assert: (self executeShould: aBlock inScopeOf: anExceptionalEvent) not.
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
    "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
   323
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
shouldnt: aBlock raise: anExceptionalEvent description: aString
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   326
    "during the execution of aBlock, the anExceptionalEvent should NOT be raised.
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   327
     If not, report aString as failure-description."
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
    self
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   332
        assert: (self executeShould: aBlock inScopeOf: anExceptionalEvent) not
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   333
        description: aString.
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
    "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
   336
!
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   337
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   338
skip
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   339
    "skip this test"
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   340
    
650
20c408a44d5d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
   341
    self skipIf:true description:'Test Skipped'.
649
a69fdedffe06 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   342
!
a69fdedffe06 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   343
674
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   344
skip:messageString
649
a69fdedffe06 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   345
    "skip this test"
a69fdedffe06 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   346
    
674
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   347
    self skipIf:true description:messageString
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   348
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   349
    "Modified (format): / 12-02-2017 / 22:44:11 / cg"
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   350
!
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
skipIf:aCondition description:messageString
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   353
    "skip this test, if some condition is met"
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   354
    
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   355
    aCondition value ifTrue: [
674
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   356
        self logSkipped: 'Skipped - ',messageString.
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   357
        TestResult skipped sunitSignalWith: messageString
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   358
    ].
674
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   359
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   360
    "Modified (format): / 12-02-2017 / 22:44:17 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
!TestAsserter methodsFor:'convenience'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   365
assert:anObject equals:anotherObject
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   366
    ^ self 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   367
        assert: anObject = anotherObject
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   368
        description: [ anObject printString, ' is not equal to ', anotherObject printString ].
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   369
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   370
    "Modified: / 13-07-2017 / 15:12:26 / cg"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   371
!
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   372
721
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
   373
assert:anObject isAtLeast:anotherObject
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
   374
    ^ self 
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
   375
        assert: anObject >= anotherObject
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
   376
        description: [ anObject printString, ' is less than ', anotherObject printString ].
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
   377
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
   378
    "Created: / 26-08-2018 / 18:01:14 / Claus Gittinger"
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
   379
!
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
   380
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   381
assertCollection:actual equals:expected
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   382
    "specialized test method that generates a proper error message for collection"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   383
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   384
    ^ self 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   385
        assert:(expected = actual)
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   386
        description:[ self class comparingCollectionBetween:actual and:expected ]
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   387
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   388
    "
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   389
     self basicNew assertCollection:#(1 2 3) equals:#(1 2 3)
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   390
     self basicNew assertCollection:#(1 2 3) equals:#(1 2 3 4)
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   391
    "
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   392
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   393
    "Created: / 13-07-2017 / 13:46:51 / cg"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   394
    "Modified (comment): / 13-07-2017 / 15:03:28 / cg"
222
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
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
!TestAsserter methodsFor:'logging'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
logFailure: aString
729
5df0b62db3d7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
   400
    self class logFailure: aString.
5df0b62db3d7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
   401
5df0b62db3d7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
   402
    "Modified (format): / 22-03-2019 / 12:48:48 / Claus Gittinger"
551
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   403
!
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   404
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   405
logSkipped: aString
729
5df0b62db3d7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
   406
    self class logSkipped: aString.
5df0b62db3d7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
   407
5df0b62db3d7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 721
diff changeset
   408
    "Modified (format): / 22-03-2019 / 12:47:27 / Claus Gittinger"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
!TestAsserter methodsFor:'private'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
executeShould: execBlock inScopeOf: exceptionalEvent
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
    <resource: #skipInDebuggersWalkBack>
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
    ^ self
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
	executeShould: execBlock
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
	inScopeOf: exceptionalEvent
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
	suchThat: [:ex | true ]
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
    "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
   423
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
executeShould: execBlock inScopeOf: exceptionalEvent suchThat: conditionBlock
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
	^[execBlock value.
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
	false]
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
		sunitOn: exceptionalEvent
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
		do:
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
		    [:ex |
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
		    ex sunitExitWith:(conditionBlock value: ex)]
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
    "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
   434
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   436
!TestAsserter class methodsFor:'documentation'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
286
01b3ae052203 changed: #executionTime
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   438
version
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   439
    ^ '$Header$'
286
01b3ae052203 changed: #executionTime
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   440
!
01b3ae052203 changed: #executionTime
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   441
223
354de0061492 initial checkin
Claus Gittinger <cg@exept.de>
parents: 222
diff changeset
   442
version_CVS
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   443
    ^ '$Header$'
223
354de0061492 initial checkin
Claus Gittinger <cg@exept.de>
parents: 222
diff changeset
   444
!
354de0061492 initial checkin
Claus Gittinger <cg@exept.de>
parents: 222
diff changeset
   445
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
version_SVN
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   447
    ^ '$Id$'
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
! !
551
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   449