TestCase.st
author Claus Gittinger <cg@exept.de>
Thu, 28 Mar 2019 13:35:41 +0100
changeset 740 7f2cc93c7a75
parent 737 a4f9d8da94aa
child 745 418e472d0744
permissions -rw-r--r--
#DOCUMENTATION by cg class: TestSuite comment/format in: #run:beforeEachDo:afterEachDo: #run:beforeEachDo:afterEachDo:resetResources: #run:beforeEachDo:afterEachDo:resetResources:debug:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
     1
"{ Package: 'stx:goodies/sunit' }"
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
599
400bc2cb5690 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
     3
"{ NameSpace: Smalltalk }"
400bc2cb5690 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
     4
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
     5
TestAsserter subclass:#TestCase
377
71ada743cae2 removed leftover rubbish
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
     6
	instanceVariableNames:'testSelector'
71ada743cae2 removed leftover rubbish
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
     7
	classVariableNames:''
71ada743cae2 removed leftover rubbish
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
     8
	poolDictionaries:''
71ada743cae2 removed leftover rubbish
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
     9
	category:'SUnit-Base'
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
!
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
    12
TestCase class instanceVariableNames:'lastOutcomes'
81
10852410025d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 73
diff changeset
    13
10852410025d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 73
diff changeset
    14
"
10852410025d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 73
diff changeset
    15
 No other class instance variables are inherited by this class.
10852410025d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 73
diff changeset
    16
"
10852410025d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 73
diff changeset
    17
!
10852410025d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 73
diff changeset
    18
717
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    19
Object subclass:#Should
719
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
    20
	instanceVariableNames:'assertSelector shouldNot value testCase'
717
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    21
	classVariableNames:''
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    22
	poolDictionaries:''
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    23
	privateIn:TestCase
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    24
!
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    25
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    26
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    27
!TestCase class methodsFor:'initialization'!
12
4a6597527f92 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6
diff changeset
    28
435
vrany
parents: 433
diff changeset
    29
flushAll
vrany
parents: 433
diff changeset
    30
vrany
parents: 433
diff changeset
    31
    "Flush all remembered outcomes in all testcases"
vrany
parents: 433
diff changeset
    32
vrany
parents: 433
diff changeset
    33
    self withAllSubclassesDo:[:cls|
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
    34
	cls flushRememberedOutcomes
435
vrany
parents: 433
diff changeset
    35
    ]
vrany
parents: 433
diff changeset
    36
vrany
parents: 433
diff changeset
    37
    "Created: / 17-11-2011 / 19:18:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
vrany
parents: 433
diff changeset
    38
!
vrany
parents: 433
diff changeset
    39
vrany
parents: 433
diff changeset
    40
flushRememberedOutcomes
vrany
parents: 433
diff changeset
    41
vrany
parents: 433
diff changeset
    42
    "Flushes all remembered outcomes for the receiver"
vrany
parents: 433
diff changeset
    43
vrany
parents: 433
diff changeset
    44
    | outcomes |
vrany
parents: 433
diff changeset
    45
vrany
parents: 433
diff changeset
    46
    lastOutcomes isNil ifTrue:[^self].
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
    47
    outcomes := lastOutcomes.
435
vrany
parents: 433
diff changeset
    48
    lastOutcomes := nil.
vrany
parents: 433
diff changeset
    49
    outcomes do:[:outcome|
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
    50
	self lastTestRunResultChanged: outcome selector.
435
vrany
parents: 433
diff changeset
    51
    ]
vrany
parents: 433
diff changeset
    52
vrany
parents: 433
diff changeset
    53
    "Created: / 17-11-2011 / 19:17:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
vrany
parents: 433
diff changeset
    54
!
vrany
parents: 433
diff changeset
    55
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    56
initialize
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    57
    ResumableTestFailure autoload
138
90efce9992ea *** empty log message ***
boris
parents: 131
diff changeset
    58
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    59
    "
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    60
     self initialize
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    61
    "
326
4732cd296e5f added: #postAutoload
Stefan Vogel <sv@exept.de>
parents: 305
diff changeset
    62
!
4732cd296e5f added: #postAutoload
Stefan Vogel <sv@exept.de>
parents: 305
diff changeset
    63
4732cd296e5f added: #postAutoload
Stefan Vogel <sv@exept.de>
parents: 305
diff changeset
    64
postAutoload
433
592799735a04 changed: #postAutoload
sr
parents: 430
diff changeset
    65
    |pd|
592799735a04 changed: #postAutoload
sr
parents: 430
diff changeset
    66
592799735a04 changed: #postAutoload
sr
parents: 430
diff changeset
    67
    (pd := self projectDefinitionClass) notNil ifTrue:[
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
    68
	pd loadExtensions
433
592799735a04 changed: #postAutoload
sr
parents: 430
diff changeset
    69
    ]
592799735a04 changed: #postAutoload
sr
parents: 430
diff changeset
    70
592799735a04 changed: #postAutoload
sr
parents: 430
diff changeset
    71
    "Modified: / 02-11-2011 / 15:44:58 / sr"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    72
! !
138
90efce9992ea *** empty log message ***
boris
parents: 131
diff changeset
    73
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    74
!TestCase class methodsFor:'instance creation'!
2
6f450bf08bc0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1
diff changeset
    75
288
3a993cee08a0 added: #asTestCase
Claus Gittinger <cg@exept.de>
parents: 282
diff changeset
    76
asTestCase
3a993cee08a0 added: #asTestCase
Claus Gittinger <cg@exept.de>
parents: 282
diff changeset
    77
    ^ self
3a993cee08a0 added: #asTestCase
Claus Gittinger <cg@exept.de>
parents: 282
diff changeset
    78
3a993cee08a0 added: #asTestCase
Claus Gittinger <cg@exept.de>
parents: 282
diff changeset
    79
    "Created: / 02-08-2011 / 09:12:13 / cg"
3a993cee08a0 added: #asTestCase
Claus Gittinger <cg@exept.de>
parents: 282
diff changeset
    80
!
3a993cee08a0 added: #asTestCase
Claus Gittinger <cg@exept.de>
parents: 282
diff changeset
    81
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    82
debug: aSymbol
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    83
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
    84
	^(self selector: aSymbol) debug
138
90efce9992ea *** empty log message ***
boris
parents: 131
diff changeset
    85
!
2
6f450bf08bc0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1
diff changeset
    86
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    87
run: aSymbol
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    88
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
    89
	^(self selector: aSymbol) run
138
90efce9992ea *** empty log message ***
boris
parents: 131
diff changeset
    90
!
90efce9992ea *** empty log message ***
boris
parents: 131
diff changeset
    91
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
selector: aSymbol
103
ad6897ce99e0 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
    93
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
    94
	^self new setTestSelector: aSymbol
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    95
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    96
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    97
suite
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    98
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
    99
	^self buildSuite
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
! !
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   102
!TestCase class methodsFor:'accessing'!
66
31ae5b8fc382 category rename
Claus Gittinger <cg@exept.de>
parents: 65
diff changeset
   103
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   104
allTestSelectors
328
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   105
    | answer pivotClass lookupRoot |
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   106
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   107
    answer := Set withAll: self testSelectors.
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   108
    self shouldInheritSelectors ifTrue:[
669
5c60313710b3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   109
        pivotClass := self superclass.
5c60313710b3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   110
        lookupRoot := self lookupHierarchyRoot.
5c60313710b3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   111
        [pivotClass == lookupRoot] whileFalse:[
5c60313710b3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   112
            answer addAll: pivotClass testSelectors.
5c60313710b3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   113
            pivotClass := pivotClass superclass.
5c60313710b3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   114
        ]
328
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   115
    ].
669
5c60313710b3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   116
    answer := answer asOrderedCollection.
5c60313710b3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   117
    answer sort.
5c60313710b3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   118
    ^ answer 
420
84e640399605 changed: #allTestSelectors
Claus Gittinger <cg@exept.de>
parents: 417
diff changeset
   119
421
9b8b2a70d775 changed: #allTestSelectors
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
   120
    "Modified: / 21-08-2011 / 15:06:11 / cg"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   121
!
66
31ae5b8fc382 category rename
Claus Gittinger <cg@exept.de>
parents: 65
diff changeset
   122
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   123
forgetLastTestRunResult
390
c2c3895aabd6 changed: #forgetLastTestRunResult
vrany
parents: 382
diff changeset
   124
c2c3895aabd6 changed: #forgetLastTestRunResult
vrany
parents: 382
diff changeset
   125
    Smalltalk changed:#lastTestRunResult with:(Array with:self with:nil).
c2c3895aabd6 changed: #forgetLastTestRunResult
vrany
parents: 382
diff changeset
   126
    self changed:#lastTestRunResult.
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   127
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   128
    "Modified: / 06-08-2006 / 11:40:07 / cg"
390
c2c3895aabd6 changed: #forgetLastTestRunResult
vrany
parents: 382
diff changeset
   129
    "Modified: / 20-08-2011 / 15:10:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   130
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   131
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   132
isTestSelector:aSelector
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   133
705
8158508603f3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
   134
    ^aSelector notNil 
8158508603f3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
   135
    and:[(aSelector startsWith:'test')
8158508603f3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
   136
    "/ temporary hack - the callers of testCount should use countTests instead
8158508603f3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
   137
    and:[aSelector ~= 'testCount']]
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   138
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   139
    "Created: / 06-08-2006 / 11:46:17 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   140
    "Modified: / 05-12-2009 / 18:50:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
290
7b52b68d57cb changed: #isTestSelector:
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   141
    "Modified: / 02-08-2011 / 17:46:51 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   142
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   143
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   144
lastTestRunResultOrNil
578
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   145
    "Returns a state (TestResult stateXXX), depending
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   146
     on the state of the tests:
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   147
	statePass if all tests passed,
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   148
	stateError if any error,
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   149
	stateFail if any fail,
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   150
     or nil if never run
578
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   151
    "
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   152
578
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   153
    |anyFail|
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   154
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   155
    lastOutcomes isNil ifTrue:[^nil].
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   156
    lastOutcomes size ~= self testSelectors size ifTrue:[^nil].
578
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   157
    anyFail := false.
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   158
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   159
    lastOutcomes do:[:outcome|
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   160
	outcome result == (TestResult stateError) ifTrue:[
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   161
	    ^ TestResult stateError
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   162
	].
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   163
	outcome result == (TestResult stateFail) ifTrue:[
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   164
	    anyFail := true
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   165
	].
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   166
    ].
578
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   167
    anyFail ifTrue:[ ^ TestResult stateFail ].
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   168
    ^ TestResult statePass
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   169
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   170
    "Modified: / 20-08-2011 / 14:59:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   171
!
87
24e88e7f5d88 remember individual failed cases.
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
   172
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   173
lookupHierarchyRoot
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   174
	^TestCase
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   175
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   176
523
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   177
rememberOutcome: thisOutcome
626
4653000fda69 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
   178
    |thisTestCase someOtherOutcome someOtherTestCase    
4653000fda69 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
   179
     thisTestCaseSelector thisTestCaseClassName|
523
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   180
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   181
    thisTestCase := thisOutcome testCase.
626
4653000fda69 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
   182
    thisTestCaseSelector := thisTestCase selector.
4653000fda69 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
   183
    thisTestCaseClassName := thisTestCase class name.
4653000fda69 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
   184
    
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   185
    lastOutcomes isNil ifTrue:[
626
4653000fda69 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
   186
        lastOutcomes := OrderedCollection new.
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   187
    ].
445
874deaef2599 changed:
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   188
523
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   189
    "Not a nice code, but portable (what: doWithIndex: is not portable?)"
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   190
    1 to: lastOutcomes size do:[:i|
626
4653000fda69 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
   191
        someOtherOutcome := lastOutcomes at: i.
4653000fda69 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
   192
        someOtherTestCase := someOtherOutcome testCase.
4653000fda69 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
   193
        "/ compare by classes name - in case it got redefined
4653000fda69 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
   194
        (someOtherTestCase selector == thisTestCaseSelector
4653000fda69 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
   195
        and: [someOtherTestCase class name = thisTestCaseClassName]) ifTrue:[
4653000fda69 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
   196
            "remember; for the timestamp and other info"
4653000fda69 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
   197
            lastOutcomes at: i put: thisOutcome.
4653000fda69 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
   198
            someOtherOutcome result ~= thisOutcome result ifTrue:[
4653000fda69 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
   199
                "but only send out change notification to browser if state has changed"
4653000fda69 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
   200
                self lastTestRunResultChanged: thisOutcome selector.
4653000fda69 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
   201
            ].
4653000fda69 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
   202
            ^self.
4653000fda69 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
   203
        ].
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   204
    ].
523
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   205
    lastOutcomes add: thisOutcome.
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   206
    self lastTestRunResultChanged: thisOutcome selector.
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   207
    ^self
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   208
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   209
    "Created: / 20-08-2011 / 12:43:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
445
874deaef2599 changed:
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   210
    "Modified: / 04-06-2012 / 16:19:07 / cg"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   211
!
81
10852410025d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 73
diff changeset
   212
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   213
rememberedOutcomeFor: selector
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   214
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   215
    lastOutcomes isNil ifTrue:[^nil].
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   216
    ^lastOutcomes
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   217
	detect: [:outcome| outcome testCase selector == selector]
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   218
	ifNone:[nil].
87
24e88e7f5d88 remember individual failed cases.
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
   219
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   220
    "Created: / 20-08-2011 / 14:27:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   221
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   222
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   223
resources
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   224
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   225
	^#()
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   226
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   227
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   228
shouldFork
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   229
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   230
    ^false
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   231
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   232
    "Created: / 13-06-2011 / 16:46:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
103
ad6897ce99e0 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   233
!
ad6897ce99e0 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   234
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   235
sunitVersion
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   236
	^'4.0'
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   237
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   238
391
fb104ea5136f added: #testSelector:result:
vrany
parents: 390
diff changeset
   239
testSelector:selector result: result
523
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   240
    "return true, if the last run of this test had the outcome result"
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   241
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   242
    lastOutcomes isNil ifTrue:[^false].
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   243
    ^ lastOutcomes
607
8d830a63bfc0 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   244
        contains:[:any|
8d830a63bfc0 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   245
            |tc|
8d830a63bfc0 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   246
8d830a63bfc0 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   247
            (tc := any testCase) class name = self name
8d830a63bfc0 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   248
            and:[tc selector == selector
8d830a63bfc0 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   249
            and:[any result == result]]
8d830a63bfc0 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   250
        ]
391
fb104ea5136f added: #testSelector:result:
vrany
parents: 390
diff changeset
   251
fb104ea5136f added: #testSelector:result:
vrany
parents: 390
diff changeset
   252
    "Created: / 20-08-2011 / 16:15:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
445
874deaef2599 changed:
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   253
    "Modified: / 04-06-2012 / 16:12:17 / cg"
391
fb104ea5136f added: #testSelector:result:
vrany
parents: 390
diff changeset
   254
!
fb104ea5136f added: #testSelector:result:
vrany
parents: 390
diff changeset
   255
fb104ea5136f added: #testSelector:result:
vrany
parents: 390
diff changeset
   256
testSelectorError:selector
523
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   257
    "return true, if the last run of this test failed"
391
fb104ea5136f added: #testSelector:result:
vrany
parents: 390
diff changeset
   258
523
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   259
    ^self testSelector: selector result: (TestResult stateError)
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   260
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   261
    "Created: / 15-03-2010 / 19:44:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   262
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   263
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   264
testSelectorFailed:selector
523
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   265
    "return true, if the last run of this test failed"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   266
523
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   267
    ^self testSelector: selector result: (TestResult stateFail)
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   268
391
fb104ea5136f added: #testSelector:result:
vrany
parents: 390
diff changeset
   269
    "Modified: / 20-08-2011 / 16:16:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   270
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   271
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   272
testSelectorPassed:selector
523
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   273
    "return true, if the last run of this test passed"
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   274
523
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   275
   ^self testSelector: selector result: (TestResult statePass)
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   276
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   277
    "Created: / 15-03-2010 / 17:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   278
!
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   279
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   280
testSelectorSkipped:selector
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   281
    "return true, if the last run of this test was skipped"
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   282
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   283
   ^self testSelector: selector result: (TestResult stateSkip)
211
3a40b828ce9a comment/format in: #testSelectors
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   284
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   285
    "Created: / 15-03-2010 / 17:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
607
8d830a63bfc0 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   286
!
8d830a63bfc0 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   287
8d830a63bfc0 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   288
testSelectorsWithLastOutcomes
8d830a63bfc0 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   289
    lastOutcomes isNil ifTrue:[^#()].
8d830a63bfc0 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 601
diff changeset
   290
    ^lastOutcomes collect:[:outcome| outcome testCase selector] as:Set
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   291
! !
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   292
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   293
!TestCase class methodsFor:'building suites'!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   294
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   295
buildSuite
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   296
	| suite |
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   297
	self isAbstract
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   298
		ifTrue:
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   299
			[suite := self suiteClass named: self name asString.
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   300
			self allSubclasses
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   301
				do: [:each | each isAbstract ifFalse: [suite addTest: each buildSuiteFromSelectors]].
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   302
			^ suite]
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   303
		ifFalse: [^ self buildSuiteFromSelectors]
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   304
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   305
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   306
buildSuiteFromMethods: testMethods
68
9fd111438d60 category renames (lower case)
Claus Gittinger <cg@exept.de>
parents: 67
diff changeset
   307
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   308
	^testMethods
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   309
		inject: (self suiteClass named: self name asString)
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   310
		into: [:suite :selector |
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   311
			suite
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   312
				addTest: (self selector: selector);
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   313
				yourself]
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   314
!
138
90efce9992ea *** empty log message ***
boris
parents: 131
diff changeset
   315
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   316
buildSuiteFromSelectors
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   317
	^self buildSuiteFromMethods: self allTestSelectors
68
9fd111438d60 category renames (lower case)
Claus Gittinger <cg@exept.de>
parents: 67
diff changeset
   318
!
9fd111438d60 category renames (lower case)
Claus Gittinger <cg@exept.de>
parents: 67
diff changeset
   319
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   320
suiteClass
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   321
	^TestSuite
68
9fd111438d60 category renames (lower case)
Claus Gittinger <cg@exept.de>
parents: 67
diff changeset
   322
! !
9fd111438d60 category renames (lower case)
Claus Gittinger <cg@exept.de>
parents: 67
diff changeset
   323
203
ca0c9f44ee72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   324
!TestCase class methodsFor:'misc ui support'!
ca0c9f44ee72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   325
ca0c9f44ee72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   326
iconInBrowserSymbol
630
5b0539adf1c1 comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   327
    "the browser will use this as index into the toolbariconlibrary"
5b0539adf1c1 comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   328
203
ca0c9f44ee72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   329
    <resource: #programImage>
ca0c9f44ee72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   330
205
2236d74e0703 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
   331
    |lastResult|
2236d74e0703 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
   332
203
ca0c9f44ee72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   333
    self theNonMetaclass isAbstract ifTrue:[^ super iconInBrowserSymbol].
205
2236d74e0703 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
   334
2236d74e0703 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
   335
    lastResult := self lastTestRunResultOrNil.
578
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   336
    lastResult notNil ifTrue:[
630
5b0539adf1c1 comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   337
        lastResult == TestResult statePass ifTrue:[
5b0539adf1c1 comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   338
            ^ #testCasePassedIcon
5b0539adf1c1 comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   339
        ].
5b0539adf1c1 comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   340
        lastResult == TestResult stateFail ifTrue:[
5b0539adf1c1 comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   341
            ^ #testCaseFailedIcon
5b0539adf1c1 comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   342
        ].
5b0539adf1c1 comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   343
        lastResult == TestResult stateError ifTrue:[
5b0539adf1c1 comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   344
            ^ #testCaseErrorIcon
5b0539adf1c1 comment/format in: #iconInBrowserSymbol
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   345
        ].
205
2236d74e0703 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
   346
    ].
203
ca0c9f44ee72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   347
    ^ #testCaseClassIcon
ca0c9f44ee72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   348
! !
ca0c9f44ee72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   349
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   350
!TestCase class methodsFor:'private'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   351
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   352
addSelector: selector to: collection
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   353
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   354
    "Adds given selector from collection. Answers
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   355
     true iff selector was really added"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   356
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   357
    (collection includes: selector)
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   358
	ifTrue:[^ false]
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   359
	ifFalse:[collection add: selector. ^ true]
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   360
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   361
    "Created: / 15-03-2010 / 18:06:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   362
    "Modified: / 21-04-2010 / 23:19:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   363
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   364
689
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   365
coveredClasses
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   366
    "return a collection of classes which are tested by this suite/case.
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   367
     Do not redefine this; redefine either coveredClassNames or
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   368
     coveredPackageNames 
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   369
     (these return names, to avoid creating
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   370
      a package dependecy due to the class references)
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   371
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   372
     These classes can be instrumented for coverage analysis,
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   373
     before running the suite to provide coverage analysis/report"
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   374
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   375
    |names|
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   376
    
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   377
    (names := self coveredPackageNames) notEmptyOrNil ifTrue:[
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   378
        ^ names 
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   379
            collectAll:[:eachPackageOrPattern |
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   380
                eachPackageOrPattern includesMatchCharacters ifTrue:[
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   381
                    Smalltalk allClassesForWhich:[:cls | (cls package ?'') matches:eachPackageOrPattern].
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   382
                ] ifFalse:[    
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   383
                    Smalltalk allClassesInPackage:eachPackageOrPattern
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   384
                ]
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   385
        ].
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   386
    ].
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   387
    ^ self coveredClassNames collect:[:each | Smalltalk classNamed:each]
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   388
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   389
    "Modified (comment): / 30-08-2017 / 11:09:22 / cg"
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   390
!
d8d6e704ac8f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 688
diff changeset
   391
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   392
lastTestRunResultChanged: selector
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   393
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   394
    Smalltalk changed:#lastTestRunResult with:(Array with:self with:selector).
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   395
    self changed:#lastTestRunResult with:selector.
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   396
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   397
    "Created: / 15-03-2010 / 19:15:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   398
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   399
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   400
testSelectors
669
5c60313710b3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   401
    "The API method is allTestSelectors which now includes #shouldInheritSelectors and so handles all cases.  Unlike that method, this does not guarantee to return a sorted ordered collection."
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   402
669
5c60313710b3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   403
    |selectors|
5c60313710b3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   404
    
5c60313710b3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   405
    selectors := self sunitSelectors 
5c60313710b3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   406
                    select: [:each | 'test*' sunitMatch: each].
5c60313710b3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   407
    selectors := selectors asOrderedCollection.
5c60313710b3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   408
    selectors sort.
5c60313710b3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 648
diff changeset
   409
    ^ selectors
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   410
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   411
417
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   412
!TestCase class methodsFor:'queries'!
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   413
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   414
coveredClassNames
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   415
    "should be redefined to return a collection of classes which are tested by
600
71cb19568d8b class: TestCase
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   416
     this suite/case. 
71cb19568d8b class: TestCase
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   417
     If not redefined, coveredPackageNames should be.
599
400bc2cb5690 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   418
400bc2cb5690 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   419
     These classes can be instrumented for coverage analysis,
600
71cb19568d8b class: TestCase
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   420
     before running the suite to provide coverage analysis/report"
417
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   421
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   422
    ^ #()
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   423
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   424
    "Created: / 06-07-2011 / 21:27:03 / cg"
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   425
!
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   426
599
400bc2cb5690 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   427
coveredPackageNames
400bc2cb5690 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   428
    "redefine this in a concrete testCase class to return non-nil,
400bc2cb5690 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   429
     to return a collection of packages which are tested by this suite/case.
400bc2cb5690 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   430
     If not redefined, coveredClassNames should be redefined.
624
dcc5bcfd1485 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   431
     The package names may be glob patterns.
599
400bc2cb5690 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   432
     These classes can be instrumented for coverage analysis,
600
71cb19568d8b class: TestCase
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   433
     before running the suite to provide coverage analysis/report"
599
400bc2cb5690 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   434
400bc2cb5690 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   435
    ^ nil
636
0687cb5a8fd8 class: RBAbstractClass
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   436
!
0687cb5a8fd8 class: RBAbstractClass
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   437
0687cb5a8fd8 class: RBAbstractClass
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   438
isAbstract
0687cb5a8fd8 class: RBAbstractClass
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   439
        "Override to true if a TestCase subclass is Abstract and should not have
0687cb5a8fd8 class: RBAbstractClass
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   440
        TestCase instances built from it"
0687cb5a8fd8 class: RBAbstractClass
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   441
0687cb5a8fd8 class: RBAbstractClass
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   442
        ^self == TestCase
417
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   443
! !
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   444
197
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   445
!TestCase class methodsFor:'quick testing'!
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   446
686
7e6f03915ad9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 685
diff changeset
   447
assert: aBooleanOrBlock
707
cf2be5373855 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
   448
    <resource: #skipInDebuggersWalkBack>
cf2be5373855 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
   449
686
7e6f03915ad9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 685
diff changeset
   450
    ^ self new assert: aBooleanOrBlock
197
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   451
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   452
    "
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   453
     TestCase assert: true
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   454
    "
686
7e6f03915ad9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 685
diff changeset
   455
7e6f03915ad9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 685
diff changeset
   456
    "Modified (format): / 13-07-2017 / 15:13:29 / cg"
197
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   457
!
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   458
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   459
should: aBlock raise: anError
707
cf2be5373855 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
   460
    <resource: #skipInDebuggersWalkBack>
cf2be5373855 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
   461
197
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   462
    ^ self new should: aBlock raise: anError
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   463
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   464
    "
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   465
     TestCase should:[ self error ] raise: Error
587
570faa368e0d class: TestCase
Stefan Vogel <sv@exept.de>
parents: 578
diff changeset
   466
     TestCase should:[ 22 ] raise: Error
197
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   467
    "
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   468
! !
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   469
601
d8c7bcbd1b66 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 600
diff changeset
   470
!TestCase class methodsFor:'running'!
d8c7bcbd1b66 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 600
diff changeset
   471
700
2309c94fe81c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 690
diff changeset
   472
debug
2309c94fe81c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 690
diff changeset
   473
    "run myself as a suite with debugging; return the result"
2309c94fe81c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 690
diff changeset
   474
2309c94fe81c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 690
diff changeset
   475
    ^ self suite debug
2309c94fe81c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 690
diff changeset
   476
2309c94fe81c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 690
diff changeset
   477
    "
2309c94fe81c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 690
diff changeset
   478
     SOAP::XeXMLTests run
2309c94fe81c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 690
diff changeset
   479
     RegressionTests::OperatingSystemTest run
2309c94fe81c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 690
diff changeset
   480
    "
2309c94fe81c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 690
diff changeset
   481
!
2309c94fe81c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 690
diff changeset
   482
601
d8c7bcbd1b66 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 600
diff changeset
   483
run
688
e2428b24d753 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 686
diff changeset
   484
    "run myself as a suite; return the result"
e2428b24d753 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 686
diff changeset
   485
e2428b24d753 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 686
diff changeset
   486
    ^ self suite run
601
d8c7bcbd1b66 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 600
diff changeset
   487
d8c7bcbd1b66 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 600
diff changeset
   488
    "
d8c7bcbd1b66 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 600
diff changeset
   489
     SOAP::XeXMLTests run
688
e2428b24d753 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 686
diff changeset
   490
     RegressionTests::OperatingSystemTest run
601
d8c7bcbd1b66 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 600
diff changeset
   491
    "
d8c7bcbd1b66 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 600
diff changeset
   492
! !
d8c7bcbd1b66 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 600
diff changeset
   493
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   494
!TestCase class methodsFor:'testing'!
103
ad6897ce99e0 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   495
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   496
isTestCaseLike
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   497
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   498
    ^true
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   499
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   500
    "Created: / 06-03-2011 / 00:16:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   501
!
103
ad6897ce99e0 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   502
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   503
rememberResult:result
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   504
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   505
    result outcomesDo:[:outcome|self rememberOutcome: outcome].
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   506
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   507
    "Created: / 05-08-2006 / 12:33:08 / cg"
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   508
    "Modified: / 20-08-2011 / 14:02:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   509
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   510
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   511
runTests
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   512
391
fb104ea5136f added: #testSelector:result:
vrany
parents: 390
diff changeset
   513
    ^self suite run
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   514
265
125e4f132d46 remember execution time (needed to generate prober reports)
Claus Gittinger <cg@exept.de>
parents: 262
diff changeset
   515
    "Modified: / 30-07-2011 / 09:26:11 / cg"
391
fb104ea5136f added: #testSelector:result:
vrany
parents: 390
diff changeset
   516
    "Modified: / 20-08-2011 / 16:14:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   517
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   518
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   519
shouldInheritSelectors
710
82df3be055a8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
   520
    "I should inherit from an Abstract superclass but not from a concrete one by default, 
82df3be055a8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
   521
     unless I have no testSelectors in which case I must be expecting to inherit them from my superclass.  
82df3be055a8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
   522
     If a test case with selectors wants to inherit selectors from a concrete superclass, 
82df3be055a8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
   523
     override this to true in that subclass."
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   524
710
82df3be055a8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
   525
        ^self ~~ self lookupHierarchyRoot
82df3be055a8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
   526
                and: [self superclass isAbstract
82df3be055a8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 707
diff changeset
   527
                        or: [self testSelectors isEmpty]]
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   528
! !
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   529
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   530
!TestCase methodsFor:'accessing'!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   531
700
2309c94fe81c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 690
diff changeset
   532
countTests
2309c94fe81c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 690
diff changeset
   533
2309c94fe81c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 690
diff changeset
   534
    ^1
2309c94fe81c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 690
diff changeset
   535
2309c94fe81c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 690
diff changeset
   536
    "Created: / 04-08-2011 / 13:03:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2309c94fe81c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 690
diff changeset
   537
!
2309c94fe81c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 690
diff changeset
   538
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   539
resources
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   540
	"We give TestCase this instance-side method so that methods polymorphic with TestSuite can be code-identical.  Having this instance-side method also helps when writing tests of resource behaviour. Except for such tests, it is rare to override this method and should not be done without thought.  If there were a good reason why a single test case needed to share tests requiring different resources, it might be legitimate."
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   541
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   542
	^self class resources
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   543
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   544
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   545
selector
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   546
	^testSelector
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   547
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   548
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   549
shouldFork
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   550
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   551
    ^self class shouldFork
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   552
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   553
    "Created: / 13-06-2011 / 16:45:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
305
f532271f8daa added testCount to TestCase & TestSuite
vrany
parents: 296
diff changeset
   554
!
f532271f8daa added testCount to TestCase & TestSuite
vrany
parents: 296
diff changeset
   555
529
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   556
shouldSkip
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   557
    "Returns true, if this testcase should be skipped when a testsuite is run.
648
6d39f37eb1cd #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   558
     This only a hint, a test runner is not obliged to respect return value.
6d39f37eb1cd #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   559
     To skip a test, mark the method with a <skip> annotation
529
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   560
     Currently, the only user is stx/goodies/builder/reports"
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   561
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   562
    | method |
648
6d39f37eb1cd #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   563
    
529
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   564
    method := self class lookupMethodFor: testSelector.
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   565
    method annotationsAt:#ignore orAt: #skip do:[:annotation|
648
6d39f37eb1cd #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
   566
         ^true
529
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   567
    ].
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   568
    ^false
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   569
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   570
    "Created: / 28-11-2012 / 18:03:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
703
7cf6ad732dc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
   571
!
7cf6ad732dc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
   572
7cf6ad732dc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
   573
testCount
7cf6ad732dc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
   574
    "obsoleted, because all methods starting with 'test'
7cf6ad732dc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
   575
     are considered to be tests; so this is a bad name;
705
8158508603f3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
   576
     please use countTests.
8158508603f3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
   577
     See TestCase >> isTestSelector:"
703
7cf6ad732dc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
   578
7cf6ad732dc9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
   579
    ^ self countTests
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   580
! !
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   581
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   582
!TestCase methodsFor:'accessing & queries'!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   583
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   584
unfinished
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   585
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   586
	"indicates an unfinished test"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   587
! !
97
1f7ff8664715 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 95
diff changeset
   588
1f7ff8664715 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 95
diff changeset
   589
!TestCase methodsFor:'assertions'!
66
31ae5b8fc382 category rename
Claus Gittinger <cg@exept.de>
parents: 65
diff changeset
   590
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   591
assert:aBlock completesInSeconds:aNumber
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   592
    "fail, if aBlock does not finish its work in aNumber seconds"
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   593
179
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   594
    <resource: #skipInDebuggersWalkBack>
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   595
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   596
    |done process semaphore|
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   597
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   598
    done := false.
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   599
    semaphore := Semaphore new.
174
3fff3dede568 #assert:completedInSeconds:
Stefan Vogel <sv@exept.de>
parents: 139
diff changeset
   600
    process := [
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   601
	aBlock value.
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   602
	done := true.
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   603
	semaphore signal
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   604
    ] fork.
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   605
    semaphore waitWithTimeout: aNumber.
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   606
    process terminate.
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   607
    self assert: done
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   608
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   609
    "
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   610
     self new assert:[Delay waitForSeconds:2] completesInSeconds:1
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   611
    "
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   612
    "
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   613
     self new assert:[Delay waitForSeconds:1] completesInSeconds:2
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   614
    "
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   615
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   616
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   617
assert: aBoolean message:messageIfFailing
531
13776d5be378 class: TestCase
vrany
parents: 529
diff changeset
   618
     <resource: #skipInDebuggersWalkBack>
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   619
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   620
    ^self assert: aBoolean description: messageIfFailing
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   621
531
13776d5be378 class: TestCase
vrany
parents: 529
diff changeset
   622
    "Modified: / 15-12-2012 / 17:20:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   623
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   624
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   625
assertFalse:aBoolean
179
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   626
    <resource: #skipInDebuggersWalkBack>
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   627
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   628
    ^ self assert:aBoolean not
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   629
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   630
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   631
assertFalse:aBoolean named:testName
179
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   632
    <resource: #skipInDebuggersWalkBack>
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   633
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   634
    ^ self assert:aBoolean not
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   635
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   636
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   637
assertTrue:aBoolean
179
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   638
    <resource: #skipInDebuggersWalkBack>
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   639
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   640
    ^ self assert:aBoolean
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   641
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   642
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   643
assertTrue:aBoolean named:testName
179
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   644
    <resource: #skipInDebuggersWalkBack>
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   645
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   646
    ^ self assert:aBoolean
66
31ae5b8fc382 category rename
Claus Gittinger <cg@exept.de>
parents: 65
diff changeset
   647
! !
31ae5b8fc382 category rename
Claus Gittinger <cg@exept.de>
parents: 65
diff changeset
   648
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   649
!TestCase methodsFor:'dependencies'!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   650
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   651
addDependentToHierachy: anObject
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   652
	"an empty method. for Composite compability with TestSuite"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   653
!
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   654
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   655
removeDependentFromHierachy: anObject
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   656
	"an empty method. for Composite compability with TestSuite"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   657
! !
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   658
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   659
!TestCase methodsFor:'deprecated'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   660
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   661
should: aBlock
707
cf2be5373855 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
   662
    <resource: #skipInDebuggersWalkBack>
cf2be5373855 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
   663
cf2be5373855 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
   664
    self assert: aBlock value
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   665
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   666
712
61e5116a2649 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   667
should:result be:expected 
61e5116a2649 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   668
    <resource: #skipInDebuggersWalkBack>
61e5116a2649 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   669
61e5116a2649 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   670
    ^ self assert: (result = expected) 
61e5116a2649 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   671
           description: 'should be ' , expected asString , ', but it''s ' , result asString
61e5116a2649 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   672
61e5116a2649 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   673
    "
61e5116a2649 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   674
     self new should:5 be:6
61e5116a2649 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   675
    "
61e5116a2649 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   676
!
61e5116a2649 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   677
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   678
should: aBlock description: aString
707
cf2be5373855 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
   679
    <resource: #skipInDebuggersWalkBack>
cf2be5373855 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
   680
cf2be5373855 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
   681
    self assert: aBlock value description: aString
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   682
!
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   683
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   684
shouldnt: aBlock
707
cf2be5373855 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
   685
    <resource: #skipInDebuggersWalkBack>
cf2be5373855 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
   686
    self deny: aBlock value
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   687
!
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   688
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   689
shouldnt: aBlock description: aString
707
cf2be5373855 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
   690
    <resource: #skipInDebuggersWalkBack>
cf2be5373855 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
   691
    self deny: aBlock value description: aString
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   692
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   693
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   694
signalFailure: aString
707
cf2be5373855 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
   695
    <resource: #skipInDebuggersWalkBack>
cf2be5373855 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 706
diff changeset
   696
    TestResult failure sunitSignalWith: aString.
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   697
! !
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   698
733
89e7550d114b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 731
diff changeset
   699
!TestCase methodsFor:'initialize / release'!
89e7550d114b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 731
diff changeset
   700
89e7550d114b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 731
diff changeset
   701
setUp
89e7550d114b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 731
diff changeset
   702
    "can be redefined in a concrete test"
89e7550d114b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 731
diff changeset
   703
!
89e7550d114b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 731
diff changeset
   704
89e7550d114b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 731
diff changeset
   705
tearDown
89e7550d114b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 731
diff changeset
   706
    "can be redefined in a concrete test"
89e7550d114b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 731
diff changeset
   707
! !
89e7550d114b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 731
diff changeset
   708
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   709
!TestCase methodsFor:'printing'!
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   710
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   711
getTestName
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   712
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   713
    ^testSelector.
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   714
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   715
    "Modified: / 05-12-2009 / 17:47:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   716
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   717
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   718
name
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   719
	^ self class name.
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   720
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   721
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   722
printOn: aStream
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   723
	self class printOn:aStream.
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   724
	aStream nextPutAll: '>>#'.
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   725
	testSelector printOn:aStream.
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   726
! !
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   727
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   728
!TestCase methodsFor:'private'!
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   729
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   730
executeShould: aBlock inScopeOf: anExceptionalEvent
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   731
"/        ^[aBlock value.
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   732
"/        false] sunitOn: anExceptionalEvent
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   733
"/                do: [:ex | ex sunitExitWith: true]
103
ad6897ce99e0 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   734
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   735
"/        [[aBlock value]
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   736
"/                on: anExceptionalEvent
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   737
"/                do: [:ex | ^true]]
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   738
"/                        on: TestResult exError
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   739
"/                        do: [:ex | ^false].
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   740
	[aBlock value]
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   741
		on: anExceptionalEvent
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   742
		do: [:ex | ^true].
103
ad6897ce99e0 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   743
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   744
	^false.
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   745
!
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   746
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   747
performTest
717
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   748
    "handle unimplemented #should message,
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   749
     so we can write:
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   750
        somthing should be:expectedResult
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   751
    "
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   752
    
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   753
    MessageNotUnderstood handle:[:ex |
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   754
        ex selector == #should ifTrue:[
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   755
            ex proceedWith:( Should new testCase:self; value:ex receiver )
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   756
        ].    
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   757
        ex reject.
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   758
    ] do:[        
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   759
        self perform: testSelector sunitAsSymbol
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   760
    ].
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   761
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   762
    "Modified: / 01-07-2018 / 12:12:10 / Claus Gittinger"
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   763
!
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   764
576
55ef6aaf19cb class: TestCase
Stefan Vogel <sv@exept.de>
parents: 575
diff changeset
   765
safeTearDown
55ef6aaf19cb class: TestCase
Stefan Vogel <sv@exept.de>
parents: 575
diff changeset
   766
    "Have to handle Abort. When tearDown is called as inside an ensure block after
55ef6aaf19cb class: TestCase
Stefan Vogel <sv@exept.de>
parents: 575
diff changeset
   767
     an abort in the debugger of an errornous test case and raises an error with a debugger
55ef6aaf19cb class: TestCase
Stefan Vogel <sv@exept.de>
parents: 575
diff changeset
   768
     itself."
55ef6aaf19cb class: TestCase
Stefan Vogel <sv@exept.de>
parents: 575
diff changeset
   769
55ef6aaf19cb class: TestCase
Stefan Vogel <sv@exept.de>
parents: 575
diff changeset
   770
    AbortOperationRequest handle:[:ex| ] do:[self tearDown].
55ef6aaf19cb class: TestCase
Stefan Vogel <sv@exept.de>
parents: 575
diff changeset
   771
!
55ef6aaf19cb class: TestCase
Stefan Vogel <sv@exept.de>
parents: 575
diff changeset
   772
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   773
setTestSelector: aSymbol
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   774
	testSelector := aSymbol
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   775
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   776
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   777
signalFailure:aString resumable:isResumable
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   778
    "/        TestResult failure sunitSignalWith: aString
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   779
179
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   780
    <resource: #skipInDebuggersWalkBack>
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   781
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   782
    isResumable ifTrue:[
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   783
	TestResult resumableFailure
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   784
	    raiseRequestWith:nil
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   785
	    errorString:aString
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   786
	    in:thisContext sender sender
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   787
    ] ifFalse:[
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   788
	TestResult failure
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   789
	    raiseErrorString:aString
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   790
	    in:thisContext sender sender
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   791
    ].
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   792
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   793
    "Modified: / 06-08-2006 / 22:55:55 / cg"
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   794
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   795
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   796
signalUnavailableResources
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   797
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   798
    self resources do:[:res |
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   799
	res isAvailable ifFalse:[
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   800
	    ^ res signalInitializationError
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   801
	]
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   802
    ].
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   803
! !
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   804
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   805
!TestCase methodsFor:'queries'!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   806
690
cb50d1d3ffeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 689
diff changeset
   807
isLogging
728
c628d3d488f1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
   808
    "By default, we're not logging failures. If you override this in
c628d3d488f1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
   809
     a subclass, make sure that you override #failureLog"
690
cb50d1d3ffeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 689
diff changeset
   810
728
c628d3d488f1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
   811
    ^ self class isLogging
c628d3d488f1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
   812
c628d3d488f1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
   813
    "Modified: / 22-03-2019 / 12:48:09 / Claus Gittinger"
690
cb50d1d3ffeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 689
diff changeset
   814
!
cb50d1d3ffeb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 689
diff changeset
   815
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   816
isTestCase
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   817
    ^ true
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   818
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   819
221
914934672e32 added: #isTestCaseLike
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
   820
isTestCaseLike
914934672e32 added: #isTestCaseLike
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
   821
    ^ true
914934672e32 added: #isTestCaseLike
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
   822
914934672e32 added: #isTestCaseLike
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
   823
    "Created: / 29-06-2011 / 20:37:57 / cg"
914934672e32 added: #isTestCaseLike
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
   824
!
914934672e32 added: #isTestCaseLike
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
   825
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   826
isTestSuite
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   827
    ^ false
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   828
! !
122
61e456491017 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   829
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   830
!TestCase methodsFor:'running'!
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   831
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   832
debug
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   833
587
570faa368e0d class: TestCase
Stefan Vogel <sv@exept.de>
parents: 578
diff changeset
   834
    | testCase outcome result wasProceeded|
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   835
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   836
    [
685
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   837
        result := TestResult stateError.
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   838
        wasProceeded := false.
587
570faa368e0d class: TestCase
Stefan Vogel <sv@exept.de>
parents: 578
diff changeset
   839
685
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   840
        [
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   841
            (testCase := self class selector: testSelector) runCase.
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   842
            wasProceeded ifFalse:[
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   843
                result := TestResult statePass.
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   844
            ]
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   845
        ] sunitOn:(TestResult failure) do: [:ex |
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   846
            ex creator == TestSkipped ifTrue:[
731
8980c4ec29ec #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 728
diff changeset
   847
                TestSkipped isHandled ifTrue:[ex reject].
685
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   848
                result := TestResult stateSkip.
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   849
            ] ifFalse:[
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   850
                result := TestResult stateFail.
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   851
            ].
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   852
            "I want a debugger to open here..."
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   853
            "the only really portable dialect query..."
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   854
            ((Smalltalk respondsTo:#isSmalltalkX) and:[Smalltalk isSmalltalkX]) ifTrue:[
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   855
                "/ debug
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   856
                Debugger
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   857
                    enter:ex raiseContext
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   858
                    withMessage:(ex description)
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   859
                    mayProceed:true.
706
1c3bc0e12b31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 705
diff changeset
   860
                ex creator == TestSkipped ifTrue:[ex return].
685
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   861
                wasProceeded := true.
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   862
                ex proceed.
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   863
            ] ifFalse:[
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   864
                "is there a portable way to open a debugger?"
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   865
                self halt:(ex description).
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   866
                wasProceeded := true.
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   867
            ].
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   868
        ].
524
5cf0a462356a lastState fixes
Claus Gittinger <cg@exept.de>
parents: 523
diff changeset
   869
685
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   870
    ] ensure: [
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   871
        " if proceeded in the debugger, we arrive here; "
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   872
        " but still, this is not always a pass !! "
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   873
        outcome := TestCaseOutcome new.
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   874
        outcome testCase: testCase.
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   875
        outcome result: result.
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   876
        outcome remember.
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   877
        TestResource resetResources: self resources
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   878
    ].
254
7f4b9fc9756b changed: #debug - remembers test as passed if no error occur during debugging
vrany
parents: 240
diff changeset
   879
7f4b9fc9756b changed: #debug - remembers test as passed if no error occur during debugging
vrany
parents: 240
diff changeset
   880
    "Modified: / 07-07-2011 / 11:10:50 / jv"
7f4b9fc9756b changed: #debug - remembers test as passed if no error occur during debugging
vrany
parents: 240
diff changeset
   881
    "Modified: / 07-07-2011 / 11:34:08 / Jan Vrany <jan.vrant@fit.cvut,cz>"
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   882
    "Modified: / 20-08-2011 / 14:15:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
685
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   883
    "Modified: / 13-07-2017 / 14:02:47 / cg"
731
8980c4ec29ec #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 728
diff changeset
   884
    "Modified: / 23-03-2019 / 10:15:15 / Claus Gittinger"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   885
!
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   886
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   887
debugAsFailure
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   888
	| semaphore |
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   889
	semaphore := Semaphore new.
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   890
	[semaphore wait. TestResource resetResources: self resources] fork.
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   891
	(self class selector: testSelector) runCaseAsFailure: semaphore.
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   892
!
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   893
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   894
debugUsing:aSymbol
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   895
    self signalUnavailableResources.
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   896
    [
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   897
	"/ used to be:
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   898
	"/  (self class selector:testSelector) perform:aSymbol
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   899
	"/ which is bad for subclasses which need more arguments.
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   900
	"/ why not use:
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   901
	"/  self copy perform:aSymbol
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   902
	"/ or even
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   903
	"/  self perform:aSymbol
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   904
	self perform:aSymbol
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   905
    ] ensure:[
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   906
	self resources do:[:each |
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   907
	    each reset
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   908
	]
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   909
    ]
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   910
!
103
ad6897ce99e0 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   911
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   912
failureLog
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   913
	^SUnitNameResolver class >> #defaultLogDevice
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   914
!
103
ad6897ce99e0 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   915
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   916
logFailure: aString
728
c628d3d488f1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
   917
    self isLogging ifTrue: [
c628d3d488f1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
   918
        self failureLog cr; nextPutAll: aString; flush
c628d3d488f1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
   919
    ]
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   920
728
c628d3d488f1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
   921
    "Modified (format): / 22-03-2019 / 12:49:30 / Claus Gittinger"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   922
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   923
550
cf72a67f1973 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   924
logSkipped: aString
728
c628d3d488f1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
   925
    self isLogging ifTrue: [
c628d3d488f1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
   926
        self failureLog cr; nextPutAll: aString; flush
c628d3d488f1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
   927
    ]
c628d3d488f1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
   928
c628d3d488f1 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
   929
    "Modified (format): / 22-03-2019 / 12:49:40 / Claus Gittinger"
550
cf72a67f1973 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   930
!
cf72a67f1973 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   931
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   932
openDebuggerOnFailingTestMethod
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   933
	"SUnit has halted one step in front of the failing test method. Step over the 'self halt' and
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   934
	 send into 'self perform: testSelector' to see the failure from the beginning"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   935
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   936
	self
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   937
		"/halt;
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   938
		performTest
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   939
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   940
    "Modified: / 05-12-2009 / 18:40:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   941
!
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   942
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   943
run
688
e2428b24d753 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 686
diff changeset
   944
    "run this suite; return the result"
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   945
461
c4a68cc4e547 use TestResultForSTX in SUnit runner
Claus Gittinger <cg@exept.de>
parents: 454
diff changeset
   946
    ^self run: TestResult defaultResultClass new
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   947
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   948
    "Modified: / 29-07-2011 / 12:07:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   949
!
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   950
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   951
run: aResult
688
e2428b24d753 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 686
diff changeset
   952
    "run this suite; fill and return aResult"
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   953
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   954
    ^self run: aResult beforeEachDo: [:test :result|] afterEachDo: [:test :result|]
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   955
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   956
    "Modified: / 29-07-2011 / 12:07:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   957
!
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   958
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   959
run: aResult afterEachDo:block2
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   960
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   961
    ^self run: aResult beforeEachDo: [:test :result|] afterEachDo:block2
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   962
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   963
    "Modified: / 29-07-2011 / 12:07:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   964
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   965
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   966
run: aResult beforeEachDo:block1 afterEachDo:block2
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   967
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   968
    ^self run: aResult beforeEachDo:block1 afterEachDo:block2 resetResources: true
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   969
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   970
    "Modified: / 29-07-2011 / 12:06:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   971
!
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   972
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   973
run: result beforeEachDo: before afterEachDo: after resetResources: reset
430
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   974
    ^ self
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   975
	run: result
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   976
	beforeEachDo: before
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   977
	afterEachDo: after
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   978
	resetResources: reset
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
   979
	debug: false
430
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   980
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   981
    "Created: / 29-07-2011 / 12:04:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   982
    "Modified: / 21-08-2011 / 17:45:17 / cg"
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   983
!
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   984
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   985
run: result beforeEachDo: before afterEachDo: after resetResources: reset debug:doDebug
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   986
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   987
    "Workhorse for running a testcase. If reset is true, then
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   988
     the resources are reset, otherwise not"
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   989
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   990
    "1. Execute before block"
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   991
    "This code is ugly in Smalltalk/X but it is so because
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   992
     it is more portable - numArgs in ANSI (?)"
737
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
   993
    Smalltalk isSmalltalkX ifTrue:[ 
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
   994
        before valueWithOptionalArgument:self and:result.   
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   995
    ] ifFalse:[
737
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
   996
        before numArgs == 2 ifTrue:[
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
   997
            before value: self value: result
685
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
   998
        ] ifFalse:[
737
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
   999
            before numArgs == 1 ifTrue:[
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
  1000
                before value: self
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
  1001
            ] ifFalse:[
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
  1002
                before value.
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
  1003
            ]
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
  1004
        ].
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
  1005
    ].
737
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
  1006
    
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
  1007
    "2. Run the testcase"
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
  1008
    reset ifTrue:[
685
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1009
        [
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1010
            result runCase: self debugged:doDebug
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1011
        ] ensure: [
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1012
            TestResource resetResources: self resources
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1013
        ].
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
  1014
    ] ifFalse:[
685
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1015
        result runCase: self debugged:doDebug
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
  1016
    ].
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
  1017
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
  1018
    "3. Execute after block"
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
  1019
    "This code is ugly in Smalltalk/X but it is so because
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
  1020
     it is more portable - numArgs in ANSI (?)"
737
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
  1021
    Smalltalk isSmalltalkX ifTrue:[ 
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
  1022
        after valueWithOptionalArgument:self and:result.
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
  1023
    ] ifFalse:[    
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
  1024
        after numArgs == 2 ifTrue:[
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
  1025
            after value: self value: result
685
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1026
        ] ifFalse:[
737
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
  1027
            after numArgs == 1 ifTrue:[
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
  1028
                after value: self
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
  1029
            ] ifFalse:[
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
  1030
                after value.
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
  1031
            ]
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
  1032
        ].
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
  1033
    ].
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
  1034
    ^result
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
  1035
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
  1036
    "Created: / 29-07-2011 / 12:04:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
430
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
  1037
    "Created: / 21-08-2011 / 17:44:56 / cg"
685
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1038
    "Modified: / 13-07-2017 / 14:02:53 / cg"
737
a4f9d8da94aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 733
diff changeset
  1039
    "Modified: / 28-03-2019 / 11:16:47 / Claus Gittinger"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1040
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1041
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1042
run: aResult beforeEachTestCaseDo:block1 afterEachTestCaseDo:block2
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
  1043
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
  1044
    <resource: #obsolete>
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
  1045
    self obsoleteMethodWarning: 'Use #run:beforeEachDo:afterEachDo: instead'.
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
  1046
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
  1047
    ^self run: aResult beforeEachDo:block1 afterEachDo:block2
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
  1048
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
  1049
    "Modified: / 29-07-2011 / 12:06:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1050
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1051
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1052
runCase
570
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
  1053
    |didSetup|
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
  1054
328
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
  1055
    self resources do: [:each | each availableFor: self].
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
  1056
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
  1057
    [
685
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1058
        didSetup := false.
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1059
        self setUp.
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1060
        didSetup := true.
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1061
        self performTest.
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1062
    ] ensure: [
713
75290ec5aa59 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  1063
        didSetup 
75290ec5aa59 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  1064
            ifTrue:[ self safeTearDown ]
75290ec5aa59 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  1065
            ifFalse:[ 
75290ec5aa59 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  1066
                "/ can we tearDown here????
75290ec5aa59 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  1067
                Transcript showCR:'error in setup - no teardown' 
75290ec5aa59 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  1068
                "/ self error:'error in setup' 
75290ec5aa59 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  1069
            ].
328
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
  1070
    ]
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
  1071
685
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1072
    "Modified: / 13-07-2017 / 14:03:01 / cg"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1073
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1074
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1075
runCaseAsFailure
570
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
  1076
    self setUp.
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
  1077
    [
594
617433e967e9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 587
diff changeset
  1078
	[self openDebuggerOnFailingTestMethod] ensure: [self safeTearDown]
570
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
  1079
    ] fork
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1080
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1081
    "Modified: / 21.6.2000 / 10:04:33 / Sames"
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1082
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1083
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
  1084
runCaseAsFailure: aSemaphore
570
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
  1085
    [
685
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1086
        |didSetup|
570
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
  1087
685
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1088
        didSetup := false.
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1089
        self resources do: [:each | each availableFor: self].
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1090
        [
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1091
            self setUp.
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1092
            didSetup := true.
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1093
            self openDebuggerOnFailingTestMethod
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1094
        ] ensure: [
713
75290ec5aa59 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  1095
            didSetup 
75290ec5aa59 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  1096
                ifTrue:[ self tearDown ]
75290ec5aa59 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  1097
                ifFalse:[ 
75290ec5aa59 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  1098
                    "/ can we tearDown here????
75290ec5aa59 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  1099
                    Transcript showCR:'error in setup - no teardown' 
75290ec5aa59 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  1100
                    "/ self error:'error in setup' 
75290ec5aa59 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  1101
                ].
685
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1102
        ]
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1103
    ] ensure: [aSemaphore signal].
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1104
00195d0e5ebc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 669
diff changeset
  1105
    "Modified: / 13-07-2017 / 14:03:44 / cg"
50
6db52a1a4543 updgraded to 3.0
Claus Gittinger <cg@exept.de>
parents: 40
diff changeset
  1106
! !
6db52a1a4543 updgraded to 3.0
Claus Gittinger <cg@exept.de>
parents: 40
diff changeset
  1107
717
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1108
!TestCase::Should class methodsFor:'documentation'!
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1109
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1110
documentation
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1111
"
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1112
    documentation to be added.
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1113
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1114
    [author:]
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1115
        Claus Gittinger
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1116
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1117
    [instance variables:]
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1118
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1119
    [class variables:]
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1120
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1121
    [see also:]
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1122
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1123
"
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1124
! !
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1125
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1126
!TestCase::Should methodsFor:'accessing'!
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1127
719
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1128
assertSelector
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1129
    ^ assertSelector ? #'assert:'
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1130
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1131
    "Created: / 01-07-2018 / 12:42:00 / Claus Gittinger"
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1132
!
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1133
717
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1134
testCase:something
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1135
    testCase := something.
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1136
!
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1137
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1138
value:something
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1139
    value := something.
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1140
! !
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1141
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1142
!TestCase::Should methodsFor:'verifying'!
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1143
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1144
be:expectedValue
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1145
    "for expressions like:
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1146
        value should be:expectedValue
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1147
     inside a testcase"
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1148
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1149
    <resource: #skipInDebuggersWalkBack>
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1150
719
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1151
    testCase perform:self assertSelector with:(value = expectedValue).
717
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1152
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1153
    "Created: / 01-07-2018 / 12:11:46 / Claus Gittinger"
719
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1154
!
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1155
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1156
beInstanceOf:expectedClass
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1157
    "for expressions like:
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1158
        value should be:expectedValue
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1159
     inside a testcase"
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1160
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1161
    <resource: #skipInDebuggersWalkBack>
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1162
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1163
    testCase perform:self assertSelector with:(value class == expectedClass).
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1164
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1165
    "Created: / 01-07-2018 / 12:38:38 / Claus Gittinger"
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1166
!
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1167
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1168
equal:expectedValue
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1169
    "for expressions like:
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1170
        value should equal:expectedValue
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1171
     inside a testcase"
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1172
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1173
    <resource: #skipInDebuggersWalkBack>
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1174
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1175
    testCase perform:self assertSelector with:(value = expectedValue).
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1176
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1177
    "Created: / 01-07-2018 / 12:30:08 / Claus Gittinger"
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1178
!
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1179
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1180
not
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1181
    assertSelector := #deny:
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1182
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1183
    "Created: / 01-07-2018 / 12:42:12 / Claus Gittinger"
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1184
!
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1185
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1186
raise:exceptionClass
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1187
    "for expressions like:
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1188
        value should be:expectedValue
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1189
     inside a testcase"
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1190
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1191
    <resource: #skipInDebuggersWalkBack>
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1192
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1193
    self assertSelector == #assert: ifTrue:[
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1194
        testCase should:value raise:exceptionClass
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1195
    ] ifFalse:[
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1196
        self assertSelector == #deny: ifTrue:[
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1197
            testCase shouldnt:value raise:exceptionClass
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1198
        ] ifFalse:[
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1199
            self error.
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1200
        ].    
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1201
    ].
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1202
2c96860ad5cb #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 717
diff changeset
  1203
    "Created: / 01-07-2018 / 12:39:48 / Claus Gittinger"
717
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1204
! !
31366612f433 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
  1205
12
4a6597527f92 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6
diff changeset
  1206
!TestCase class methodsFor:'documentation'!
4a6597527f92 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6
diff changeset
  1207
290
7b52b68d57cb changed: #isTestSelector:
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1208
version
623
Claus Gittinger <cg@exept.de>
parents: 607
diff changeset
  1209
    ^ '$Header$'
290
7b52b68d57cb changed: #isTestSelector:
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1210
!
7b52b68d57cb changed: #isTestSelector:
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1211
203
ca0c9f44ee72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
  1212
version_CVS
623
Claus Gittinger <cg@exept.de>
parents: 607
diff changeset
  1213
    ^ '$Header$'
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
  1214
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
  1215
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
  1216
version_SVN
623
Claus Gittinger <cg@exept.de>
parents: 607
diff changeset
  1217
    ^ '$Id$'
12
4a6597527f92 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6
diff changeset
  1218
! !
81
10852410025d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 73
diff changeset
  1219
550
cf72a67f1973 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
  1220
2
6f450bf08bc0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1
diff changeset
  1221
TestCase initialize!