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