TestCaseOutcome.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 14 Jul 2014 21:58:21 +0100
branchworking_v5_0
changeset 614 3003097506c9
parent 589 b7cd9f791bb1
child 615 f1b888de7817
permissions -rw-r--r--
Refactored remembering of TestCaseOutcomes. TestCaseOutcomes are no longer remembered in class instance var of the TestCase but rather in one global dictionary on TestCaseOutcome class. The top-level weak dictionary uses test method as a key and second-level dictionary as value. This ensures that when a test method is changed, sooner or later (now obsolete) remebered outcomes are reclamed by the GC. The second-level dictionary uses test case class as a key and outcome as value. This is used to keep outcomes for inherited test cases. This dictionary is also weak, ensuring that when the class is unloaded or changed, outcomes are reclamed. To reduce a number of weak objects a special TestCaseOutcomeWeakIdentityDictionary is used. It optimizes the most common case when there are no inherited testcases.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
360
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
     1
"{ Package: 'stx:goodies/sunit' }"
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
     2
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
     3
Object subclass:#TestCaseOutcome
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
     4
	instanceVariableNames:'testCase result properties'
614
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
     5
	classVariableNames:'RemeberedOutcomes'
360
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
     6
	poolDictionaries:''
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
     7
	category:'SUnit-Base'
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
     8
!
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
     9
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    10
!TestCaseOutcome class methodsFor:'documentation'!
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    11
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    12
documentation
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    13
"
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    14
    will keep additional info for a testCase run:
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    15
        startTime, endTime,
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    16
        backtrace (if fail or error)
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    17
        and collectedStdout
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    18
"
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    19
! !
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    20
614
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    21
!TestCaseOutcome class methodsFor:'initialization'!
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    22
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    23
initialize
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    24
    "Invoked at system start or when the class is dynamically loaded."
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    25
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    26
    "/ please change as required (and remove this comment)
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    27
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    28
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    29
    RemeberedOutcomes := SUnitNameResolver weakIdentityDictionaryClass new
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    30
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    31
    "Modified: / 14-07-2014 / 09:59:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    32
! !
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    33
360
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    34
!TestCaseOutcome class methodsFor:'instance creation'!
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    35
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    36
forCase: aTestCase
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    37
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    38
    ^self new testCase: aTestCase; yourself
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    39
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    40
    "Created: / 16-08-2011 / 15:24:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    41
! !
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    42
614
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    43
!TestCaseOutcome class methodsFor:'notifying'!
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    44
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    45
notifyOutcomeChanged: currentOutcome ifDifferentFrom: previousOutcome
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    46
    "Notifies whoever is interested that the current outcome for a testcase has
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    47
     changed, but only if result of the current (pass, fail or error) is actually 
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    48
     different the result of previous outcome"   
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    49
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    50
    (previousOutcome isNil or:[ previousOutcome result ~~ currentOutcome result ]) ifTrue:[ 
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    51
        currentOutcome testCase class lastTestRunResultChanged:currentOutcome testCase selector         
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    52
    ].
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    53
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    54
    "Created: / 14-07-2014 / 21:07:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    55
! !
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    56
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    57
!TestCaseOutcome class methodsFor:'remembering'!
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    58
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    59
rememberOutcome: current
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    60
    | method outcomes previous |    
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    61
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    62
    method := current method.                                    
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    63
    outcomes := RemeberedOutcomes at: method ifAbsent:[ RemeberedOutcomes at: method put: TestCaseOutcomeWeakIdentityDictionary new ]. 
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    64
    previous := outcomes at: current testCase class ifAbsent:[ nil ].
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    65
    outcomes at: current testCase class put: current.
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    66
    self notifyOutcomeChanged: current ifDifferentFrom: previous.
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    67
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    68
    "Created: / 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: 589
diff changeset
    69
    "Modified: / 14-07-2014 / 21:16:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    70
!
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    71
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    72
rememberedOutcomeFor: selector in: class
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    73
    | implementor method outcomes |
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    74
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    75
    implementor := class.
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    76
    [implementor notNil and:[implementor includesSelector: selector]]
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    77
            whileFalse: [implementor := implementor superclass].
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    78
    implementor isNil ifTrue:[ ^ nil ].
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    79
    method := implementor compiledMethodAt: selector.                   
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    80
    outcomes := RemeberedOutcomes at: method ifAbsent:[ ^ nil ].
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    81
    ^ outcomes at: class ifAbsent: [ nil ]
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    82
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    83
    "Created: / 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: 589
diff changeset
    84
    "Modified: / 14-07-2014 / 21:15:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    85
! !
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
    86
360
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    87
!TestCaseOutcome methodsFor:'accessing'!
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    88
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    89
collectedOutput
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    90
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    91
    ^self propertyAt: #collectedOutput
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    92
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    93
    "Modified: / 16-08-2011 / 15:27:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    94
    "Created: / 16-08-2011 / 18:19:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    95
!
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    96
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    97
collectedOutput: aString
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    98
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
    99
    ^self propertyAt: #collectedOutput put: aString
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   100
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   101
    "Modified: / 16-08-2011 / 15:28:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   102
    "Created: / 16-08-2011 / 18:19:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   103
!
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   104
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   105
endTime
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   106
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   107
    ^self propertyAt: #endTime
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   108
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   109
    "Modified: / 16-08-2011 / 15:28:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   110
!
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   111
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   112
endTime: anObject
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   113
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   114
    ^self propertyAt: #endTime put: anObject
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   115
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   116
    "Modified: / 16-08-2011 / 15:28:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   117
!
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   118
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   119
exceptionDetail
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   120
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   121
    ^self propertyAt: #exceptionDetail
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   122
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   123
    "Modified: / 16-08-2011 / 15:29:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   124
!
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   125
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   126
exceptionDetail: anObject
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   127
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   128
    ^self propertyAt: #exceptionDetail put: anObject
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   129
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   130
    "Modified: / 16-08-2011 / 15:29:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   131
!
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   132
379
065605384740 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   133
executionTime
065605384740 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   134
    "the execution time in millis; nil if not yet executed"
065605384740 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   135
065605384740 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   136
    |startTime endTime|
065605384740 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   137
065605384740 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   138
    (startTime := self startTime) isNil ifTrue:[
065605384740 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   139
        "/ not yet executed
065605384740 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   140
        ^ nil
065605384740 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   141
    ].
065605384740 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   142
    (endTime := self endTime) isNil ifTrue:[
065605384740 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   143
        "/ assume it is still running...
065605384740 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   144
        endTime := Timestamp now
065605384740 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   145
    ].
589
b7cd9f791bb1 class: TestCaseOutcome
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   146
    ^ (endTime millisecondDeltaFrom:startTime)
379
065605384740 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   147
065605384740 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   148
    "Modified (format): / 18-08-2011 / 21:02:28 / cg"
065605384740 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   149
!
065605384740 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   150
614
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
   151
method
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
   152
    "Return the CompiledMethod corresponding to this test case in as dialect-neutral a way as possible.  We code on the assumption there must be one. If there isn't and we work up to nil superclass then fail, not bothering with implementor isNil ifTrue: [^nil] as we assume the caller would immediately fail in that case."
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
   153
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
   154
    | implementor |
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
   155
    implementor := testCase class.
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
   156
    [implementor includesSelector: testCase selector]
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
   157
            whileFalse: [implementor := implementor superclass].
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
   158
    ^ implementor compiledMethodAt: testCase selector
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
   159
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
   160
    "Created: / 13-07-2014 / 23:31:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
   161
!
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
   162
360
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   163
propertyAt: aSymbol
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   164
379
065605384740 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   165
    ^ self propertyAt: aSymbol ifAbsent: [nil]
360
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   166
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   167
    "Created: / 16-08-2011 / 15:26:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
379
065605384740 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   168
    "Modified: / 18-08-2011 / 21:03:01 / cg"
360
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   169
!
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   170
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   171
propertyAt: aSymbol ifAbsent: aBlock
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   172
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   173
    properties isNil ifTrue: [^aBlock value].
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   174
    ^properties at: aSymbol ifAbsent:aBlock.
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   175
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   176
    "Created: / 16-08-2011 / 15:27:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   177
!
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   178
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   179
propertyAt: aSymbol put: anObject
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   180
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   181
    properties isNil ifTrue: [properties := Dictionary new].
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   182
    properties at: aSymbol put: anObject.
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   183
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   184
    "Created: / 16-08-2011 / 15:28:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   185
!
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   186
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   187
result
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   188
    ^ result
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   189
!
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   190
419
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   191
result:aSymbol
488
53045c5fc90d class: TestCaseOutcome
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   192
    ((aSymbol ~= TestResult statePass) 
53045c5fc90d class: TestCaseOutcome
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   193
    and:[ aSymbol ~= TestResult stateFail 
53045c5fc90d class: TestCaseOutcome
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   194
    and:[ aSymbol ~= TestResult stateError
53045c5fc90d class: TestCaseOutcome
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   195
    and:[ aSymbol ~= TestResult stateSkip ]]]) ifTrue:[
419
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   196
        self error:'invalid result'.
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   197
    ].
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   198
    result := aSymbol.
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   199
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   200
    "Modified: / 20-08-2011 / 12:52:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
360
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   201
!
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   202
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   203
selector
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   204
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   205
    ^testCase selector
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   206
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   207
    "Created: / 16-08-2011 / 15:38:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   208
!
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   209
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   210
startTime
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   211
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   212
    ^self propertyAt: #startTime
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   213
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   214
    "Modified: / 16-08-2011 / 15:29:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   215
!
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   216
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   217
startTime: anObject
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   218
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   219
    ^self propertyAt: #startTime put: anObject
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   220
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   221
    "Modified: / 16-08-2011 / 15:29:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   222
!
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   223
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   224
testCase
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   225
    ^ testCase
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   226
!
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   227
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   228
testCase:something
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   229
    testCase := something.
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   230
! !
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   231
419
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   232
!TestCaseOutcome methodsFor:'comparing'!
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   233
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   234
= anotherOutcome
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   235
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   236
    ^(anotherOutcome isKindOf: self class) 
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   237
        and:[self testCase class == anotherOutcome testCase class
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   238
            and:[self testCase selector == anotherOutcome testCase selector]].
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   239
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   240
    "Created: / 20-08-2011 / 14:24:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   241
!
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   242
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   243
hash
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   244
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   245
    ^testCase hash bitXor: result hash
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   246
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   247
    "Created: / 20-08-2011 / 14:23:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   248
! !
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   249
589
b7cd9f791bb1 class: TestCaseOutcome
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   250
!TestCaseOutcome methodsFor:'printing & storing'!
b7cd9f791bb1 class: TestCaseOutcome
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   251
b7cd9f791bb1 class: TestCaseOutcome
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   252
printOn:aStream
b7cd9f791bb1 class: TestCaseOutcome
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   253
    "append a printed representation if the receiver to the argument, aStream"
b7cd9f791bb1 class: TestCaseOutcome
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   254
b7cd9f791bb1 class: TestCaseOutcome
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   255
    super printOn:aStream.
b7cd9f791bb1 class: TestCaseOutcome
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   256
    aStream nextPut:$(.
b7cd9f791bb1 class: TestCaseOutcome
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   257
    testCase printOn: aStream.
b7cd9f791bb1 class: TestCaseOutcome
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   258
    aStream nextPut:$).
b7cd9f791bb1 class: TestCaseOutcome
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   259
b7cd9f791bb1 class: TestCaseOutcome
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   260
    "Modified: / 17-07-2013 / 17:59:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
b7cd9f791bb1 class: TestCaseOutcome
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   261
! !
b7cd9f791bb1 class: TestCaseOutcome
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   262
419
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   263
!TestCaseOutcome methodsFor:'remembering'!
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   264
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   265
remember
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   266
614
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
   267
    ^TestCaseOutcome rememberOutcome: self.
419
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   268
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   269
    "Created: / 20-08-2011 / 12:45:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
614
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
   270
    "Modified: / 14-07-2014 / 21:35:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
419
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   271
! !
e2eb2ab5b937 Lost methods
vrany
parents: 379
diff changeset
   272
360
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   273
!TestCaseOutcome class methodsFor:'documentation'!
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   274
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   275
version_CVS
589
b7cd9f791bb1 class: TestCaseOutcome
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   276
    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestCaseOutcome.st,v 1.6 2014-04-16 22:06:04 cg Exp $'
360
57c87e624dc6 initial checkin
vrany
parents:
diff changeset
   277
! !
589
b7cd9f791bb1 class: TestCaseOutcome
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   278
614
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
   279
3003097506c9 Refactored remembering of TestCaseOutcomes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 589
diff changeset
   280
TestCaseOutcome initialize!