TestCase.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 27 Jan 2015 09:51:19 +0000
branchworking_v5_0
changeset 616 580add62d680
parent 614 3003097506c9
child 619 8ca8f9f83aea
permissions -rw-r--r--
Reverted TestCase>>debug to work with MiniTestRunner
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
616
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
     3
"{ NameSpace: Smalltalk }"
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
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
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    19
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    20
!TestCase class methodsFor:'initialization'!
12
4a6597527f92 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6
diff changeset
    21
435
vrany
parents: 433
diff changeset
    22
flushAll
vrany
parents: 433
diff changeset
    23
vrany
parents: 433
diff changeset
    24
    "Flush all remembered outcomes in all testcases"
vrany
parents: 433
diff changeset
    25
vrany
parents: 433
diff changeset
    26
    self withAllSubclassesDo:[:cls|
vrany
parents: 433
diff changeset
    27
        cls flushRememberedOutcomes
vrany
parents: 433
diff changeset
    28
    ]
vrany
parents: 433
diff changeset
    29
vrany
parents: 433
diff changeset
    30
    "Created: / 17-11-2011 / 19:18:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
vrany
parents: 433
diff changeset
    31
!
vrany
parents: 433
diff changeset
    32
vrany
parents: 433
diff changeset
    33
flushRememberedOutcomes
vrany
parents: 433
diff changeset
    34
vrany
parents: 433
diff changeset
    35
    "Flushes all remembered outcomes for the receiver"
vrany
parents: 433
diff changeset
    36
vrany
parents: 433
diff changeset
    37
    | outcomes |
vrany
parents: 433
diff changeset
    38
vrany
parents: 433
diff changeset
    39
    lastOutcomes isNil ifTrue:[^self].
vrany
parents: 433
diff changeset
    40
    outcomes := lastOutcomes. 
vrany
parents: 433
diff changeset
    41
    lastOutcomes := nil.
vrany
parents: 433
diff changeset
    42
    outcomes do:[:outcome|
vrany
parents: 433
diff changeset
    43
        self lastTestRunResultChanged: outcome selector.
vrany
parents: 433
diff changeset
    44
    ]
vrany
parents: 433
diff changeset
    45
vrany
parents: 433
diff changeset
    46
    "Created: / 17-11-2011 / 19:17:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
vrany
parents: 433
diff changeset
    47
!
vrany
parents: 433
diff changeset
    48
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    49
initialize
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    50
    ResumableTestFailure autoload
138
90efce9992ea *** empty log message ***
boris
parents: 131
diff changeset
    51
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    52
    "
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    53
     self initialize
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    54
    "
326
4732cd296e5f added: #postAutoload
Stefan Vogel <sv@exept.de>
parents: 305
diff changeset
    55
!
4732cd296e5f added: #postAutoload
Stefan Vogel <sv@exept.de>
parents: 305
diff changeset
    56
4732cd296e5f added: #postAutoload
Stefan Vogel <sv@exept.de>
parents: 305
diff changeset
    57
postAutoload
433
592799735a04 changed: #postAutoload
sr
parents: 430
diff changeset
    58
    |pd|
592799735a04 changed: #postAutoload
sr
parents: 430
diff changeset
    59
592799735a04 changed: #postAutoload
sr
parents: 430
diff changeset
    60
    (pd := self projectDefinitionClass) notNil ifTrue:[
592799735a04 changed: #postAutoload
sr
parents: 430
diff changeset
    61
        pd loadExtensions
592799735a04 changed: #postAutoload
sr
parents: 430
diff changeset
    62
    ]
592799735a04 changed: #postAutoload
sr
parents: 430
diff changeset
    63
592799735a04 changed: #postAutoload
sr
parents: 430
diff changeset
    64
    "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
    65
! !
138
90efce9992ea *** empty log message ***
boris
parents: 131
diff changeset
    66
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    67
!TestCase class methodsFor:'instance creation'!
2
6f450bf08bc0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1
diff changeset
    68
288
3a993cee08a0 added: #asTestCase
Claus Gittinger <cg@exept.de>
parents: 282
diff changeset
    69
asTestCase
3a993cee08a0 added: #asTestCase
Claus Gittinger <cg@exept.de>
parents: 282
diff changeset
    70
    ^ self
3a993cee08a0 added: #asTestCase
Claus Gittinger <cg@exept.de>
parents: 282
diff changeset
    71
3a993cee08a0 added: #asTestCase
Claus Gittinger <cg@exept.de>
parents: 282
diff changeset
    72
    "Created: / 02-08-2011 / 09:12:13 / cg"
3a993cee08a0 added: #asTestCase
Claus Gittinger <cg@exept.de>
parents: 282
diff changeset
    73
!
3a993cee08a0 added: #asTestCase
Claus Gittinger <cg@exept.de>
parents: 282
diff changeset
    74
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    75
debug: aSymbol
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    76
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
    77
        ^(self selector: aSymbol) debug
138
90efce9992ea *** empty log message ***
boris
parents: 131
diff changeset
    78
!
2
6f450bf08bc0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1
diff changeset
    79
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    80
run: aSymbol
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    81
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
    82
        ^(self selector: aSymbol) run
138
90efce9992ea *** empty log message ***
boris
parents: 131
diff changeset
    83
!
90efce9992ea *** empty log message ***
boris
parents: 131
diff changeset
    84
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
selector: aSymbol
103
ad6897ce99e0 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
    86
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
    87
        ^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
    88
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    89
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    90
suite
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    91
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
    92
        ^self buildSuite
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
! !
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    95
!TestCase class methodsFor:'accessing'!
66
31ae5b8fc382 category rename
Claus Gittinger <cg@exept.de>
parents: 65
diff changeset
    96
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
    97
allTestSelectors
328
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
    98
    | answer pivotClass lookupRoot |
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
    99
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   100
    answer := Set withAll: self testSelectors.
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   101
    self shouldInheritSelectors ifTrue:[
421
9b8b2a70d775 changed: #allTestSelectors
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
   102
        pivotClass := self superclass.
328
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   103
        lookupRoot := self lookupHierarchyRoot.
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   104
        [pivotClass == lookupRoot] whileFalse:[
421
9b8b2a70d775 changed: #allTestSelectors
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
   105
            answer addAll: pivotClass testSelectors.
328
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   106
            pivotClass := pivotClass superclass.
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   107
        ]
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   108
    ].
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   109
    ^answer asSortedCollection asOrderedCollection
420
84e640399605 changed: #allTestSelectors
Claus Gittinger <cg@exept.de>
parents: 417
diff changeset
   110
421
9b8b2a70d775 changed: #allTestSelectors
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
   111
    "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
   112
!
66
31ae5b8fc382 category rename
Claus Gittinger <cg@exept.de>
parents: 65
diff changeset
   113
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   114
forgetLastTestRunResult
390
c2c3895aabd6 changed: #forgetLastTestRunResult
vrany
parents: 382
diff changeset
   115
c2c3895aabd6 changed: #forgetLastTestRunResult
vrany
parents: 382
diff changeset
   116
    Smalltalk changed:#lastTestRunResult with:(Array with:self with:nil).
c2c3895aabd6 changed: #forgetLastTestRunResult
vrany
parents: 382
diff changeset
   117
    self changed:#lastTestRunResult.
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   118
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   119
    "Modified: / 06-08-2006 / 11:40:07 / cg"
390
c2c3895aabd6 changed: #forgetLastTestRunResult
vrany
parents: 382
diff changeset
   120
    "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
   121
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   122
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   123
isTestSelector:aSelector
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   124
290
7b52b68d57cb changed: #isTestSelector:
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   125
    ^aSelector notNil and:[aSelector startsWith:'test']
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   126
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   127
    "Created: / 06-08-2006 / 11:46:17 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   128
    "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
   129
    "Modified: / 02-08-2011 / 17:46:51 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   130
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   131
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   132
lastTestRunResultOrNil
578
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   133
    "Returns a state (TestResult stateXXX), depending
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   134
     on the state of the tests:
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   135
        statePass if all tests passed,
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   136
        stateError if any error,
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   137
        stateFail if any fail,
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   138
     or nil if never run            
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   139
    "
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   140
578
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   141
    |anyFail|
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   142
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   143
    lastOutcomes isNil ifTrue:[^nil].
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   144
    lastOutcomes size ~= self testSelectors size ifTrue:[^nil].
578
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   145
    anyFail := false.
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   146
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   147
    lastOutcomes do:[:outcome|
578
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   148
        outcome result == (TestResult stateError) ifTrue:[
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   149
            ^ TestResult stateError
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   150
        ].
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   151
        outcome result == (TestResult stateFail) ifTrue:[
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   152
            anyFail := true
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   153
        ].
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   154
    ].
578
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   155
    anyFail ifTrue:[ ^ TestResult stateFail ].
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   156
    ^ TestResult statePass
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   157
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   158
    "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
   159
!
87
24e88e7f5d88 remember individual failed cases.
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
   160
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   161
lookupHierarchyRoot
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   162
        ^TestCase
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   163
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   164
523
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   165
rememberOutcome: thisOutcome
614
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 613
diff changeset
   166
    <resource: #obsolete>
445
874deaef2599 changed:
Claus Gittinger <cg@exept.de>
parents: 435
diff changeset
   167
614
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 613
diff changeset
   168
    TestCaseOutcome rememberOutcome: thisOutcome
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
    "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
   171
    "Modified: / 04-06-2012 / 16:19:07 / cg"
614
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 613
diff changeset
   172
    "Modified: / 13-07-2014 / 23:28:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 613
diff changeset
   173
    "Modified (format): / 14-07-2014 / 21:36: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
   174
!
81
10852410025d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 73
diff changeset
   175
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   176
rememberedOutcomeFor: selector
614
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 613
diff changeset
   177
    ^ TestCaseOutcome rememberedOutcomeFor: selector in: self.
87
24e88e7f5d88 remember individual failed cases.
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
   178
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   179
    "Created: / 20-08-2011 / 14:27:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
614
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 613
diff changeset
   180
    "Modified: / 13-07-2014 / 23:56:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 613
diff changeset
   181
    "Modified (comment): / 14-07-2014 / 09:43:49 / 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
   182
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   183
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   184
resources
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   185
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   186
        ^#()
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   187
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   188
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   189
shouldFork
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   190
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   191
    ^false
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   192
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   193
    "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
   194
!
ad6897ce99e0 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   195
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   196
sunitVersion
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   197
        ^'4.0'
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   198
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   199
391
fb104ea5136f added: #testSelector:result:
vrany
parents: 390
diff changeset
   200
testSelector:selector result: result
523
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   201
    "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
   202
614
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 613
diff changeset
   203
    "ST/X Specific"
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 613
diff changeset
   204
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 613
diff changeset
   205
    | outcome |
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 613
diff changeset
   206
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 613
diff changeset
   207
    outcome := self rememberedOutcomeFor: selector.
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 613
diff changeset
   208
    ^ outcome notNil and:[ outcome result == result ]
391
fb104ea5136f added: #testSelector:result:
vrany
parents: 390
diff changeset
   209
fb104ea5136f added: #testSelector:result:
vrany
parents: 390
diff changeset
   210
    "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
   211
    "Modified: / 04-06-2012 / 16:12:17 / cg"
614
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 613
diff changeset
   212
    "Modified: / 14-07-2014 / 09:44:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
391
fb104ea5136f added: #testSelector:result:
vrany
parents: 390
diff changeset
   213
!
fb104ea5136f added: #testSelector:result:
vrany
parents: 390
diff changeset
   214
fb104ea5136f added: #testSelector:result:
vrany
parents: 390
diff changeset
   215
testSelectorError:selector
523
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   216
    "return true, if the last run of this test failed"
391
fb104ea5136f added: #testSelector:result:
vrany
parents: 390
diff changeset
   217
523
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   218
    ^self testSelector: selector result: (TestResult stateError)
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   219
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   220
    "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
   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
testSelectorFailed:selector
523
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   224
    "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
   225
523
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   226
    ^self testSelector: selector result: (TestResult stateFail)
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   227
391
fb104ea5136f added: #testSelector:result:
vrany
parents: 390
diff changeset
   228
    "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
   229
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   230
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   231
testSelectorPassed:selector
523
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   232
    "return true, if the last run of this test passed"
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   233
523
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   234
   ^self testSelector: selector result: (TestResult statePass)
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   235
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   236
    "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
   237
!
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   238
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   239
testSelectorSkipped:selector
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   240
    "return true, if the last run of this test was skipped"
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   241
dbbf2521cc0c class: TestCase
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   242
   ^self testSelector: selector result: (TestResult stateSkip)
211
3a40b828ce9a comment/format in: #testSelectors
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   243
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   244
    "Created: / 15-03-2010 / 17:58: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
   245
! !
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   246
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   247
!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
   248
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   249
buildSuite
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   250
        | suite |
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   251
        ^self isAbstract
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   252
                ifTrue:
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   253
                        [suite := self suiteClass named: self name asString.
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   254
                        self allSubclasses
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   255
                                do: [:each | each isAbstract ifFalse: [suite addTest: each buildSuiteFromSelectors]].
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   256
                        suite]
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   257
                ifFalse: [self buildSuiteFromSelectors]
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   258
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   259
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   260
buildSuiteFromMethods: testMethods
68
9fd111438d60 category renames (lower case)
Claus Gittinger <cg@exept.de>
parents: 67
diff changeset
   261
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   262
        ^testMethods
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   263
                inject: (self suiteClass named: self name asString)
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   264
                into: [:suite :selector |
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   265
                        suite
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   266
                                addTest: (self selector: selector);
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   267
                                yourself]
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   268
!
138
90efce9992ea *** empty log message ***
boris
parents: 131
diff changeset
   269
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   270
buildSuiteFromSelectors
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   271
        ^self buildSuiteFromMethods: self allTestSelectors
68
9fd111438d60 category renames (lower case)
Claus Gittinger <cg@exept.de>
parents: 67
diff changeset
   272
!
9fd111438d60 category renames (lower case)
Claus Gittinger <cg@exept.de>
parents: 67
diff changeset
   273
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   274
suiteClass
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   275
        ^TestSuite
68
9fd111438d60 category renames (lower case)
Claus Gittinger <cg@exept.de>
parents: 67
diff changeset
   276
! !
9fd111438d60 category renames (lower case)
Claus Gittinger <cg@exept.de>
parents: 67
diff changeset
   277
203
ca0c9f44ee72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   278
!TestCase class methodsFor:'misc ui support'!
ca0c9f44ee72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   279
ca0c9f44ee72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   280
iconInBrowserSymbol
ca0c9f44ee72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   281
    <resource: #programImage>
ca0c9f44ee72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   282
205
2236d74e0703 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
   283
    |lastResult|
2236d74e0703 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
   284
203
ca0c9f44ee72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   285
    self theNonMetaclass isAbstract ifTrue:[^ super iconInBrowserSymbol].
205
2236d74e0703 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
   286
2236d74e0703 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
   287
    lastResult := self lastTestRunResultOrNil.
578
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   288
    lastResult notNil ifTrue:[
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   289
        lastResult == TestResult statePass ifTrue:[
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   290
            ^ #testCasePassedIcon
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   291
        ].
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   292
        lastResult == TestResult stateFail ifTrue:[
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   293
            ^ #testCaseFailedIcon
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   294
        ].
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   295
        lastResult == TestResult stateError ifTrue:[
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   296
            ^ #testCaseErrorIcon
be4d2b6894b9 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
   297
        ].
205
2236d74e0703 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 203
diff changeset
   298
    ].
203
ca0c9f44ee72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   299
    ^ #testCaseClassIcon
ca0c9f44ee72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   300
! !
ca0c9f44ee72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   301
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   302
!TestCase class methodsFor:'private'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   303
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   304
addSelector: selector to: collection
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   305
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   306
    "Adds given selector from collection. Answers
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   307
     true iff selector was really added"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   308
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   309
    ^(collection includes: selector)
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   310
        ifTrue:[false]
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   311
        ifFalse:[collection add: selector. true]
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   312
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   313
    "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
   314
    "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
   315
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   316
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   317
lastTestRunResultChanged: selector
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   318
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   319
    Smalltalk changed:#lastTestRunResult with:(Array with:self with:selector).
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   320
    self changed:#lastTestRunResult with:selector.
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   321
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   322
    "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
   323
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   324
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   325
testSelectors
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   326
        "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
   327
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   328
        ^self sunitSelectors select: [:each | 'test*' sunitMatch: each]
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   329
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   330
417
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   331
!TestCase class methodsFor:'queries'!
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   332
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   333
coveredClassNames
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   334
    "should be redefined to return a collection of classes which are tested by
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   335
     this suite/case. These classes can be instrumented for coverage analysis,
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   336
     before running the suite"
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   337
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   338
    ^ #()
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   339
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   340
    "Created: / 06-07-2011 / 21:27:03 / cg"
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   341
!
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   342
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   343
coveredClasses
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   344
    "return a collection of classes which are tested by this suite/case. 
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   345
     These classes can be instrumented for coverage analysis,
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   346
     before running the suite"
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   347
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   348
    ^ self coveredClassNames collect:[:each | Smalltalk classNamed:each]
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   349
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   350
    "Created: / 04-07-2011 / 18:16:08 / cg"
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   351
! !
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
   352
197
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   353
!TestCase class methodsFor:'quick testing'!
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   354
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   355
assert: aBoolean
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   356
    ^ self new assert: aBoolean
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   357
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   358
    "
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   359
     TestCase assert: true
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   360
    "
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   361
!
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   362
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   363
should: aBlock raise: anError
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   364
    ^ self new should: aBlock raise: anError
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   365
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   366
    "
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   367
     TestCase should:[ self error ] raise: Error
587
570faa368e0d class: TestCase
Stefan Vogel <sv@exept.de>
parents: 578
diff changeset
   368
     TestCase should:[ 22 ] raise: Error
197
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   369
    "
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   370
! !
f44d22a08808 quick tests
Claus Gittinger <cg@exept.de>
parents: 194
diff changeset
   371
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   372
!TestCase class methodsFor:'testing'!
103
ad6897ce99e0 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   373
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   374
isAbstract
326
4732cd296e5f added: #postAutoload
Stefan Vogel <sv@exept.de>
parents: 305
diff changeset
   375
        "Override to true if a TestCase subclass is Abstract and should not have
4732cd296e5f added: #postAutoload
Stefan Vogel <sv@exept.de>
parents: 305
diff changeset
   376
        TestCase instances built from it"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   377
326
4732cd296e5f added: #postAutoload
Stefan Vogel <sv@exept.de>
parents: 305
diff changeset
   378
        ^self sunitName = #TestCase
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   379
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   380
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   381
isTestCaseLike
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   382
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   383
    ^true
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   384
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   385
    "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
   386
!
103
ad6897ce99e0 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   387
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   388
rememberResult:result
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   389
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   390
    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
   391
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   392
    "Created: / 05-08-2006 / 12:33:08 / cg"
382
05683696d647 Fixs in remembering test outcomes
vrany
parents: 377
diff changeset
   393
    "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
   394
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   395
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   396
runTests
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   397
391
fb104ea5136f added: #testSelector:result:
vrany
parents: 390
diff changeset
   398
    ^self suite run
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   399
265
125e4f132d46 remember execution time (needed to generate prober reports)
Claus Gittinger <cg@exept.de>
parents: 262
diff changeset
   400
    "Modified: / 30-07-2011 / 09:26:11 / cg"
391
fb104ea5136f added: #testSelector:result:
vrany
parents: 390
diff changeset
   401
    "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
   402
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   403
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   404
shouldInheritSelectors
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   405
        "I should inherit from an Abstract superclass but not from a concrete one by default, unless I have no testSelectors in which case I must be expecting to inherit them from my superclass.  If a test case with selectors wants to inherit selectors from a concrete superclass, 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
   406
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   407
        ^self ~~ self lookupHierarchyRoot
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   408
                and: [self superclass isAbstract
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   409
                        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
   410
! !
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   411
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   412
!TestCase methodsFor:'accessing'!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   413
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   414
resources
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   415
        "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
   416
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   417
        ^self class resources
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   418
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   419
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   420
selector
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   421
        ^testSelector
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   422
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   423
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   424
shouldFork
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   425
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   426
    ^self class shouldFork
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   427
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   428
    "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
   429
!
f532271f8daa added testCount to TestCase & TestSuite
vrany
parents: 296
diff changeset
   430
529
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   431
shouldSkip
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   432
    "Returns true, if this testcase should be skipped when a testsuite is run.
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   433
     This inly a hint, a test runner is not obliged to respect return value.
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   434
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   435
     Currently, the only user is stx/goodies/builder/reports"
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   436
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   437
    | method |
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   438
    method := self class lookupMethodFor: testSelector.
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   439
    method annotationsAt:#ignore orAt: #skip do:[:annotation|
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   440
         ^true
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   441
    ].
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   442
    ^false
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   443
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   444
    "Created: / 28-11-2012 / 18:03:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   445
!
6bcbe6998b73 added: #shouldSkip
vrany
parents: 524
diff changeset
   446
305
f532271f8daa added testCount to TestCase & TestSuite
vrany
parents: 296
diff changeset
   447
testCount
f532271f8daa added testCount to TestCase & TestSuite
vrany
parents: 296
diff changeset
   448
f532271f8daa added testCount to TestCase & TestSuite
vrany
parents: 296
diff changeset
   449
    ^1
f532271f8daa added testCount to TestCase & TestSuite
vrany
parents: 296
diff changeset
   450
f532271f8daa added testCount to TestCase & TestSuite
vrany
parents: 296
diff changeset
   451
    "Created: / 04-08-2011 / 13:03:25 / 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
   452
! !
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   453
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   454
!TestCase methodsFor:'accessing & queries'!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   455
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   456
unfinished
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   457
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   458
        "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
   459
! !
97
1f7ff8664715 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 95
diff changeset
   460
1f7ff8664715 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 95
diff changeset
   461
!TestCase methodsFor:'assertions'!
66
31ae5b8fc382 category rename
Claus Gittinger <cg@exept.de>
parents: 65
diff changeset
   462
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   463
assert:aBlock completesInSeconds:aNumber
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   464
    "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
   465
179
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   466
    <resource: #skipInDebuggersWalkBack>
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   467
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   468
    |done process semaphore|
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   469
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   470
    done := false.
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   471
    semaphore := Semaphore new.
174
3fff3dede568 #assert:completedInSeconds:
Stefan Vogel <sv@exept.de>
parents: 139
diff changeset
   472
    process := [
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   473
        aBlock value.
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   474
        done := true.
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   475
        semaphore signal
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   476
    ] fork.
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   477
    semaphore waitWithTimeout: aNumber.
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   478
    process terminate.
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   479
    self assert: done
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   480
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   481
    "
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   482
     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
   483
    "
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   484
    "
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   485
     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
   486
    "
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   487
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   488
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   489
assert: aBoolean message:messageIfFailing
531
13776d5be378 class: TestCase
vrany
parents: 529
diff changeset
   490
     <resource: #skipInDebuggersWalkBack>
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   491
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   492
    ^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
   493
531
13776d5be378 class: TestCase
vrany
parents: 529
diff changeset
   494
    "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
   495
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   496
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   497
assertFalse:aBoolean
179
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   498
    <resource: #skipInDebuggersWalkBack>
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   499
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   500
    ^ self assert:aBoolean not
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   501
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   502
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   503
assertFalse:aBoolean named:testName
179
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   504
    <resource: #skipInDebuggersWalkBack>
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   505
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   506
    ^ self assert:aBoolean not
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   507
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   508
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   509
assertTrue:aBoolean
179
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   510
    <resource: #skipInDebuggersWalkBack>
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   511
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   512
    ^ self assert:aBoolean
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   513
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   514
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   515
assertTrue:aBoolean named:testName
179
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   516
    <resource: #skipInDebuggersWalkBack>
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   517
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   518
    ^ self assert:aBoolean
66
31ae5b8fc382 category rename
Claus Gittinger <cg@exept.de>
parents: 65
diff changeset
   519
! !
31ae5b8fc382 category rename
Claus Gittinger <cg@exept.de>
parents: 65
diff changeset
   520
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   521
!TestCase methodsFor:'dependencies'!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   522
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   523
addDependentToHierachy: anObject
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   524
        "an empty method. for Composite compability with TestSuite"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   525
!
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   526
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   527
removeDependentFromHierachy: anObject
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   528
        "an empty method. for Composite compability with TestSuite"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   529
! !
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   530
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   531
!TestCase methodsFor:'deprecated'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   532
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   533
should: aBlock
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   534
        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
   535
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   536
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   537
should: aBlock description: aString
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   538
        self assert: aBlock value description: aString
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   539
!
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   540
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   541
shouldnt: aBlock
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   542
        self deny: aBlock value
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   543
!
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   544
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   545
shouldnt: aBlock description: aString
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   546
        self deny: aBlock value description: aString
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
signalFailure: aString
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   550
        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
   551
! !
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   552
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   553
!TestCase methodsFor:'printing'!
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   554
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   555
getTestName
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   556
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   557
    ^testSelector.
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   558
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   559
    "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
   560
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   561
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   562
name
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   563
        ^ self class name.
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   564
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   565
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   566
printOn: aStream
587
570faa368e0d class: TestCase
Stefan Vogel <sv@exept.de>
parents: 578
diff changeset
   567
        self class printOn:aStream.
570faa368e0d class: TestCase
Stefan Vogel <sv@exept.de>
parents: 578
diff changeset
   568
        aStream nextPutAll: '>>#'.
570faa368e0d class: TestCase
Stefan Vogel <sv@exept.de>
parents: 578
diff changeset
   569
        testSelector printOn:aStream.
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   570
! !
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   571
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   572
!TestCase methodsFor:'private'!
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   573
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   574
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
   575
"/        ^[aBlock value.
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   576
"/        false] sunitOn: anExceptionalEvent
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   577
"/                do: [:ex | ex sunitExitWith: true]
103
ad6897ce99e0 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   578
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   579
"/        [[aBlock value]
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   580
"/                on: anExceptionalEvent
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   581
"/                do: [:ex | ^true]]
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   582
"/                        on: TestResult exError
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   583
"/                        do: [:ex | ^false].
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   584
        [aBlock value]
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   585
                on: anExceptionalEvent
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   586
                do: [:ex | ^true].
103
ad6897ce99e0 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   587
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   588
        ^false.
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   589
!
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   590
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   591
performTest
328
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   592
    self perform: testSelector sunitAsSymbol
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   593
!
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   594
576
55ef6aaf19cb class: TestCase
Stefan Vogel <sv@exept.de>
parents: 575
diff changeset
   595
safeTearDown
55ef6aaf19cb class: TestCase
Stefan Vogel <sv@exept.de>
parents: 575
diff changeset
   596
    "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
   597
     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
   598
     itself."
55ef6aaf19cb class: TestCase
Stefan Vogel <sv@exept.de>
parents: 575
diff changeset
   599
55ef6aaf19cb class: TestCase
Stefan Vogel <sv@exept.de>
parents: 575
diff changeset
   600
    AbortOperationRequest handle:[:ex| ] do:[self tearDown].
55ef6aaf19cb class: TestCase
Stefan Vogel <sv@exept.de>
parents: 575
diff changeset
   601
!
55ef6aaf19cb class: TestCase
Stefan Vogel <sv@exept.de>
parents: 575
diff changeset
   602
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   603
setTestSelector: aSymbol
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   604
        testSelector := aSymbol
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   605
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   606
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   607
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
   608
    "/        TestResult failure sunitSignalWith: aString
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   609
179
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   610
    <resource: #skipInDebuggersWalkBack>
caba0f640d13 context skipping in debugger generalized
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   611
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   612
    isResumable ifTrue:[
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   613
        TestResult resumableFailure
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   614
            raiseRequestWith:nil
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   615
            errorString:aString
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   616
            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
   617
    ] ifFalse:[
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   618
        TestResult failure
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   619
            raiseErrorString:aString
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   620
            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
   621
    ].
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   622
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   623
    "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
   624
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   625
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   626
signalUnavailableResources
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   627
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   628
    self resources do:[:res |
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   629
        res isAvailable ifFalse:[
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   630
            ^ res signalInitializationError
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   631
        ]
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   632
    ].
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   633
! !
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   634
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   635
!TestCase methodsFor:'queries'!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   636
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   637
isTestCase
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   638
    ^ true
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   639
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   640
221
914934672e32 added: #isTestCaseLike
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
   641
isTestCaseLike
914934672e32 added: #isTestCaseLike
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
   642
    ^ true
914934672e32 added: #isTestCaseLike
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
   643
914934672e32 added: #isTestCaseLike
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
   644
    "Created: / 29-06-2011 / 20:37:57 / cg"
914934672e32 added: #isTestCaseLike
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
   645
!
914934672e32 added: #isTestCaseLike
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
   646
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   647
isTestSuite
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   648
    ^ false
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   649
! !
122
61e456491017 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 118
diff changeset
   650
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   651
!TestCase methodsFor:'running'!
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   652
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   653
debug
616
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   654
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   655
    | testCase outcome result wasProceeded|
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   656
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   657
    [
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   658
	result := TestResult stateError.
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   659
	wasProceeded := false.
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   660
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   661
	[
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   662
	    (testCase := self class selector: testSelector) runCase.
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   663
	    wasProceeded ifFalse:[
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   664
		result := TestResult statePass.
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   665
	    ]
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   666
	] sunitOn:(TestResult failure) do: [:ex |
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   667
	    ex creator == TestSkipped ifTrue:[
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   668
		result := TestResult stateSkip.
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   669
	    ] ifFalse:[
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   670
		result := TestResult stateFail.
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   671
	    ].
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   672
	    "I want a debugger to open here..."
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   673
	    "the only really portable dialect query..."
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   674
	    ((Smalltalk respondsTo:#isSmalltalkX) and:[Smalltalk isSmalltalkX]) ifTrue:[
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   675
		"/ debug
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   676
		Debugger
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   677
		    enter:ex raiseContext
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   678
		    withMessage:(ex description)
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   679
		    mayProceed:true.
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   680
		wasProceeded := true.
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   681
		ex proceed.
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   682
	    ] ifFalse:[
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   683
		"is there a portable way to open a debugger?"
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   684
		self halt:(ex description).
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   685
		wasProceeded := true.
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   686
	    ].
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   687
	].
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   688
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   689
    ] sunitEnsure: [
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   690
	" if proceeded in the debugger, we arrive here; "
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   691
	" but still, this is not always a pass !! "
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   692
	outcome := TestCaseOutcome new.
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   693
	outcome testCase: testCase.
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   694
	outcome result: result.
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   695
	outcome remember.
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   696
	TestResource resetResources: self resources
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   697
    ].
254
7f4b9fc9756b changed: #debug - remembers test as passed if no error occur during debugging
vrany
parents: 240
diff changeset
   698
7f4b9fc9756b changed: #debug - remembers test as passed if no error occur during debugging
vrany
parents: 240
diff changeset
   699
    "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
   700
    "Modified: / 07-07-2011 / 11:34:08 / Jan Vrany <jan.vrant@fit.cvut,cz>"
616
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   701
    "Modified: / 20-08-2011 / 14:15:51 / 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
   702
!
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   703
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   704
debugAsFailure
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   705
        | semaphore |
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   706
        semaphore := Semaphore new.
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   707
        [semaphore wait. TestResource resetResources: self resources] fork.
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   708
        (self class selector: testSelector) runCaseAsFailure: semaphore.
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   709
!
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
debugUsing:aSymbol
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   712
    self signalUnavailableResources.
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   713
    [
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   714
        "/ used to be:
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   715
        "/  (self class selector:testSelector) perform:aSymbol
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   716
        "/ which is bad for subclasses which need more arguments.
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   717
        "/ why not use:
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   718
        "/  self copy perform:aSymbol
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   719
        "/ or even
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   720
        "/  self perform:aSymbol
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   721
        self perform:aSymbol
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   722
    ] ensure:[
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   723
        self resources do:[:each |
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   724
            each reset
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   725
        ]
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   726
    ]
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   727
!
103
ad6897ce99e0 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   728
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   729
failureLog
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   730
        ^SUnitNameResolver class >> #defaultLogDevice
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   731
!
103
ad6897ce99e0 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   732
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   733
isLogging
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   734
        "By default, we're not logging failures. If you override this in
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   735
        a subclass, make sure that you override #failureLog"
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   736
        ^false
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   737
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   738
!
103
ad6897ce99e0 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   739
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   740
logFailure: aString
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   741
        self isLogging ifTrue: [
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   742
                self failureLog
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   743
                        cr;
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   744
                        nextPutAll: aString;
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   745
                        flush]
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   746
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   747
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   748
550
cf72a67f1973 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   749
logSkipped: aString
cf72a67f1973 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   750
        self isLogging ifTrue: [
cf72a67f1973 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   751
                self failureLog
cf72a67f1973 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   752
                        cr;
cf72a67f1973 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   753
                        nextPutAll: aString;
cf72a67f1973 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   754
                        flush]
cf72a67f1973 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   755
!
cf72a67f1973 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   756
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   757
openDebuggerOnFailingTestMethod
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   758
        "SUnit has halted one step in front of the failing test method. Step over the 'self halt' and
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   759
         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
   760
331
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   761
        self
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   762
                "/halt;
ea59d5e02844 moved: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   763
                performTest
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   764
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   765
    "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
   766
!
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   767
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   768
run
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   769
461
c4a68cc4e547 use TestResultForSTX in SUnit runner
Claus Gittinger <cg@exept.de>
parents: 454
diff changeset
   770
    ^self run: TestResult defaultResultClass new
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   771
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   772
    "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
   773
!
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   774
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   775
run: aResult
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   776
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   777
    ^self run: aResult beforeEachDo: [:test :result|] afterEachDo: [:test :result|]
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   778
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   779
    "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
   780
!
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
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
run: aResult afterEachDo:block2
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   783
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   784
    ^self run: aResult beforeEachDo: [:test :result|] afterEachDo:block2
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   785
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   786
    "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
   787
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   788
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   789
run: aResult beforeEachDo:block1 afterEachDo:block2
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   790
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   791
    ^self run: aResult beforeEachDo:block1 afterEachDo:block2 resetResources: true
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   792
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   793
    "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
   794
!
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   795
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   796
run: result beforeEachDo: before afterEachDo: after resetResources: reset
430
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   797
    ^ self
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   798
        run: result 
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   799
        beforeEachDo: before 
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   800
        afterEachDo: after 
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   801
        resetResources: reset
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   802
        debug: false
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   803
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   804
    "Created: / 29-07-2011 / 12:04:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   805
    "Modified: / 21-08-2011 / 17:45:17 / cg"
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   806
!
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   807
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   808
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
   809
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   810
    "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
   811
     the resources are reset, otherwise not"
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   812
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   813
    "1. Execute before block"
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   814
    "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
   815
     it is more portable - numArgs in ANSI (?)"
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   816
    before numArgs == 2 ifTrue:[
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   817
        before value: self value: result                
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   818
    ] ifFalse:[
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   819
        before numArgs == 1 ifTrue:[
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   820
            before value: self
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   821
        ] ifFalse:[
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   822
            before value.
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   823
        ]
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   824
    ].
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   825
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   826
    "2. Run the testcase"
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   827
    reset ifTrue:[
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   828
        [
430
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   829
            result runCase: self debugged:doDebug
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   830
        ] sunitEnsure: [
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   831
            TestResource resetResources: self resources
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   832
        ].
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   833
    ] ifFalse:[
430
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   834
        result runCase: self debugged:doDebug
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   835
    ].
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   836
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   837
    "3. Execute after block"
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   838
    "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
   839
     it is more portable - numArgs in ANSI (?)"
282
deb55165e73b changed: #run:beforeEachDo:afterEachDo:resetResources:
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   840
    after numArgs == 2 ifTrue:[
deb55165e73b changed: #run:beforeEachDo:afterEachDo:resetResources:
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   841
        after value: self value: result                
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   842
    ] ifFalse:[
282
deb55165e73b changed: #run:beforeEachDo:afterEachDo:resetResources:
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   843
        after numArgs == 1 ifTrue:[
deb55165e73b changed: #run:beforeEachDo:afterEachDo:resetResources:
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   844
            after value: self
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   845
        ] ifFalse:[
282
deb55165e73b changed: #run:beforeEachDo:afterEachDo:resetResources:
Claus Gittinger <cg@exept.de>
parents: 265
diff changeset
   846
            after value.
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   847
        ]
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   848
    ].
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   849
    ^result
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   850
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   851
    "Created: / 29-07-2011 / 12:04:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
430
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   852
    "Created: / 21-08-2011 / 17:44:56 / cg"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   853
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   854
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   855
run: aResult beforeEachTestCaseDo:block1 afterEachTestCaseDo:block2
262
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   856
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   857
    <resource: #obsolete>
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   858
    self obsoleteMethodWarning: 'Use #run:beforeEachDo:afterEachDo: instead'.
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   859
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   860
    ^self run: aResult beforeEachDo:block1 afterEachDo:block2
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   861
3c46acd3f64a TestSuite/TestCase run* method refactored (cleanup, possible bug fixes)
vrany
parents: 254
diff changeset
   862
    "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
   863
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   864
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   865
runCase
570
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   866
    |didSetup|
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   867
328
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   868
    self resources do: [:each | each availableFor: self].
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   869
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   870
    [
570
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   871
        didSetup := false.
328
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   872
        self setUp.
570
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   873
        didSetup := true.
377
71ada743cae2 removed leftover rubbish
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   874
        self performTest.
328
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   875
    ] sunitEnsure: [
576
55ef6aaf19cb class: TestCase
Stefan Vogel <sv@exept.de>
parents: 575
diff changeset
   876
        didSetup ifTrue:[ self safeTearDown ]
328
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   877
    ]
66cae160c956 added: #withStandardOutputAndTranscriptRedirectedDo:
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   878
377
71ada743cae2 removed leftover rubbish
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   879
    "Modified (comment): / 18-08-2011 / 20:35:20 / cg"
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   880
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   881
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   882
runCaseAsFailure
570
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   883
    self setUp.
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   884
    [
576
55ef6aaf19cb class: TestCase
Stefan Vogel <sv@exept.de>
parents: 575
diff changeset
   885
        [self openDebuggerOnFailingTestMethod] ensure: [self safeTearDown]
570
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   886
    ] fork
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   887
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   888
    "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
   889
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   890
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   891
runCaseAsFailure: aSemaphore
570
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   892
    [
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   893
        |didSetup|
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   894
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   895
        didSetup := false.
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   896
        self resources do: [:each | each availableFor: self].
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   897
        [
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   898
            self setUp.
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   899
            didSetup := true.
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   900
            self openDebuggerOnFailingTestMethod
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   901
        ] sunitEnsure: [
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   902
            didSetup ifTrue:[ self tearDown ]
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   903
        ]
c9c4c97948cc class: TestCase
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
   904
    ] sunitEnsure: [aSemaphore signal].
139
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   905
!
5a48f282d789 back to 1.42 - last checked in version was bogus
Claus Gittinger <cg@exept.de>
parents: 138
diff changeset
   906
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   907
setUp
454
b95684ea4f32 comment/format in:
Claus Gittinger <cg@exept.de>
parents: 445
diff changeset
   908
    "can be redefined in a concrete test"
67
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   909
!
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   910
7861684195ec category rename
Claus Gittinger <cg@exept.de>
parents: 66
diff changeset
   911
tearDown
454
b95684ea4f32 comment/format in:
Claus Gittinger <cg@exept.de>
parents: 445
diff changeset
   912
    "can be redefined in a concrete test"
50
6db52a1a4543 updgraded to 3.0
Claus Gittinger <cg@exept.de>
parents: 40
diff changeset
   913
! !
6db52a1a4543 updgraded to 3.0
Claus Gittinger <cg@exept.de>
parents: 40
diff changeset
   914
12
4a6597527f92 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6
diff changeset
   915
!TestCase class methodsFor:'documentation'!
4a6597527f92 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6
diff changeset
   916
290
7b52b68d57cb changed: #isTestSelector:
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   917
version
587
570faa368e0d class: TestCase
Stefan Vogel <sv@exept.de>
parents: 578
diff changeset
   918
    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestCase.st,v 1.104 2014-03-21 17:23:32 stefan Exp $'
290
7b52b68d57cb changed: #isTestSelector:
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   919
!
7b52b68d57cb changed: #isTestSelector:
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   920
203
ca0c9f44ee72 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   921
version_CVS
587
570faa368e0d class: TestCase
Stefan Vogel <sv@exept.de>
parents: 578
diff changeset
   922
    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestCase.st,v 1.104 2014-03-21 17:23:32 stefan Exp $'
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   923
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   924
616
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   925
version_HG
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   926
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   927
    ^ '$Changeset: <not expanded> $'
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   928
!
580add62d680 Reverted TestCase>>debug to work with MiniTestRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 614
diff changeset
   929
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 221
diff changeset
   930
version_SVN
587
570faa368e0d class: TestCase
Stefan Vogel <sv@exept.de>
parents: 578
diff changeset
   931
    ^ '$Id: TestCase.st,v 1.104 2014-03-21 17:23:32 stefan Exp $'
12
4a6597527f92 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6
diff changeset
   932
! !
81
10852410025d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 73
diff changeset
   933
550
cf72a67f1973 class: TestCase
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   934
2
6f450bf08bc0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1
diff changeset
   935
TestCase initialize!