TestResult.st
author Claus Gittinger <cg@exept.de>
Sat, 06 Aug 2011 09:34:48 +0200
changeset 316 d01820e6d817
parent 303 6d21e7a22412
child 318 96ce5904bba6
permissions -rw-r--r--
changed: #addError:detail: #addFailure:detail: #runCase:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/sunit' }"
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
Object subclass:#TestResult
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
     4
	instanceVariableNames:'name timestamp failures errors passed'
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
     5
	classVariableNames:''
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
     6
	poolDictionaries:''
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
     7
	category:'SUnit-Base'
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
     8
!
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
     9
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    10
TestResult comment:''
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
!
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
14
a4a5478621e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6
diff changeset
    13
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    14
!TestResult class methodsFor:'instance creation'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    15
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    16
new
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    17
	^super new initialize
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    18
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    19
68
9fd111438d60 category renames (lower case)
Claus Gittinger <cg@exept.de>
parents: 53
diff changeset
    20
!TestResult class methodsFor:'exceptions'!
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
error
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
    23
	^self exError
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
!
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
exError
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
    27
	^SUnitNameResolver errorObject
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
!
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
failure
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
    31
	^TestFailure
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
    32
!
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
    34
resumableFailure
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
    35
	^ResumableTestFailure
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
!
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    38
signalErrorWith: aString
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    39
	self error sunitSignalWith: aString
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    40
!
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    42
signalFailureWith: aString
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    43
	self failure sunitSignalWith: aString
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
! !
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
68
9fd111438d60 category renames (lower case)
Claus Gittinger <cg@exept.de>
parents: 53
diff changeset
    46
!TestResult methodsFor:'accessing'!
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
defects
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
    49
	^OrderedCollection new
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
    50
		addAll: self errors;
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
    51
		addAll: self failures; yourself
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
!
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
errorCount
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
    55
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
    56
	^self errors size
6
78bb1397e43d added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents: 0
diff changeset
    57
!
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
errors
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    60
	errors isNil ifTrue: [errors := OrderedCollection new].
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
    61
	^errors
6
78bb1397e43d added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents: 0
diff changeset
    62
!
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
300
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
    64
exceptions
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
    65
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
    66
    "Returns a set of exceptions to be handled. Bu default,
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
    67
     failure and generic error is handled. This method may
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
    68
     be overriden by custom TestResult subclasses to add more.
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
    69
     For example, a 'self halt' is not handled by default
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
    70
     exceptions set"
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
    71
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
    72
    ^self class failure , self class error
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
    73
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
    74
    "Created: / 03-08-2011 / 14:11:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
    75
!
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
    76
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
failureCount
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
    79
	^self failures size
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
!
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
failures
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    83
	"We use a Set, not an OrderedCollection as #errors and #passed do, because a resumable test failure in a loop can raise many failures against the same test.  In current Sunit UIs, this could result in bizarre test count reporting (-27 tests run, and suchlike).  This will be reviewed."
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    84
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    85
	failures isNil ifTrue: [failures := Set new].
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
    86
	^failures
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    87
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    88
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    89
name
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    90
    ^ name
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    91
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    92
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    93
name:aString
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    94
    name := aString.
6
78bb1397e43d added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents: 0
diff changeset
    95
!
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
53
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
    97
passed
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
    98
	passed isNil ifTrue: [passed := OrderedCollection new].
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
    99
	^passed
53
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   100
!
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   101
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   102
passedCount
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   103
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   104
	^self passed size
53
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   105
!
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   106
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
runCount
53
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   108
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   109
	^self passedCount + self failureCount + self errorCount
53
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   110
!
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   111
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   112
tests
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   113
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   114
	^(OrderedCollection new: self runCount)
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   115
		addAll: self passed;
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   116
		addAll: self errors;
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   117
		addAll: self failures;
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   118
		yourself
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   119
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   120
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   121
timestamp
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   122
    ^ timestamp
270
edb137bd861e added: #timestamp:
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   123
!
edb137bd861e added: #timestamp:
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   124
edb137bd861e added: #timestamp:
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   125
timestamp:something
edb137bd861e added: #timestamp:
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   126
    timestamp := something.
6
78bb1397e43d added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents: 0
diff changeset
   127
! !
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   129
!TestResult methodsFor:'adding'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   130
300
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   131
addError: testcase detail: detail
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   132
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   133
        "Called when a test outcome is error. testCase 
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   134
         is the errorneous testcase, detail is platform
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   135
         specific object describing the error. Actually, 
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   136
         on all platforms exept GemStone, detail is an instance 
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   137
         of an exception that caused the error"
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   138
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   139
        "JV2011-08-03: TODO: Validate the comment above with GS,
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   140
         possibly change name to 'exception'"
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   141
316
d01820e6d817 changed:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   142
        testcase exceptionInfoString:(self exceptionInfoStringFor:detail in:testcase).
d01820e6d817 changed:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   143
300
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   144
        testcase class rememberErrorTest: testcase selector.
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   145
        ^self errors add: testcase
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   146
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   147
    "Modified: / 11-09-2010 / 17:19:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
300
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   148
    "Created: / 03-08-2011 / 13:50:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
316
d01820e6d817 changed:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   149
    "Modified: / 06-08-2011 / 09:33:53 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   150
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   151
300
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   152
addFailure: testcase detail: detail
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   153
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   154
        "Called when a test fails. testCase is the failed 
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   155
         testcase, detail is platform specific object describing 
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   156
         the failure. Actually, on all platforms exept GemStone, 
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   157
         detail is an instance of an exception that caused the failure"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   158
300
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   159
        "JV2011-08-03: TODO: Validate the comment above with GS,
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   160
         possibly change name to 'exception'"
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   161
316
d01820e6d817 changed:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   162
        testcase exceptionInfoString:(self exceptionInfoStringFor:detail in:testcase).
300
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   163
        testcase class rememberFailedTest: testcase selector.
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   164
        ^self failures add: testcase
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   165
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   166
    "Created: / 03-08-2011 / 13:53:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
316
d01820e6d817 changed:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   167
    "Modified: / 06-08-2011 / 09:34:17 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   168
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   169
300
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   170
addPass: testcase
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   171
        testcase class rememberPassedTest: testcase selector.
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   172
        ^self passed add: testcase
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   173
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   174
    "Modified: / 11-09-2010 / 17:19:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   175
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   176
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   177
!TestResult methodsFor:'deprecated'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   178
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   179
correctCount
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   180
	"deprecated - use #passedCount"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   181
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   182
	^self passedCount
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   183
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   184
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   185
!TestResult methodsFor:'initialize-release'!
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
initialize
6
78bb1397e43d added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents: 0
diff changeset
   188
! !
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
68
9fd111438d60 category renames (lower case)
Claus Gittinger <cg@exept.de>
parents: 53
diff changeset
   190
!TestResult methodsFor:'printing'!
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
297
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   192
exceptionInfoStringFor:anException in:aTestCase
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   193
    "the following should be pretty portable;
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   194
     if not, comment the following, and uncomment the false
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   195
     to return nil (thats what you had before)"
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   196
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   197
    ((Smalltalk respondsTo:#isSmalltalkX) and:[Smalltalk isSmalltalkX]) 
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   198
    "false" 
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   199
    ifTrue:[
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   200
        ^ String streamContents:[:s |
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   201
            |con endReached|
292
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   202
297
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   203
            endReached := false.
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   204
            con := anException suspendedContext.
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   205
            [ con isNil or:[ endReached ]] whileFalse:[
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   206
                con printOn:s.
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   207
                s cr.
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   208
                ((con selector == aTestCase selector) 
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   209
                and:[ con receiver == aTestCase ]) ifTrue:[
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   210
                    endReached := true.
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   211
                ].
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   212
                con := con sender.
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   213
            ]
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   214
        ].
292
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   215
    ].
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   216
297
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   217
    ^ nil
292
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   218
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   219
    "Created: / 02-08-2011 / 18:10:46 / cg"
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   220
!
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   221
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
printOn: aStream
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   223
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   224
	aStream
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   225
		nextPutAll: self runCount printString;
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   226
		nextPutAll: ' run, ';
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   227
		nextPutAll: self correctCount printString;
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   228
		nextPutAll: ' passed, ';
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   229
		nextPutAll: self failureCount printString;
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   230
		nextPutAll: ' failed, ';
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   231
		nextPutAll: self errorCount printString;
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   232
		nextPutAll: ' error'.
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   233
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   234
	self errorCount ~= 1
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   235
		ifTrue: [aStream nextPut: $s]
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
! !
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
68
9fd111438d60 category renames (lower case)
Claus Gittinger <cg@exept.de>
parents: 53
diff changeset
   238
!TestResult methodsFor:'running'!
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
303
6d21e7a22412 - doRunCase: renamed to performCase:
vrany
parents: 300
diff changeset
   240
performCase:aTestCase 
6d21e7a22412 - doRunCase: renamed to performCase:
vrany
parents: 300
diff changeset
   241
    "Actually performs the case. The TestCase>>runCase itself calls
300
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   242
     a setUp/tearDown methods. The possible error/failure is handled
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   243
     in TestResult>>runCase:. This method is meant to be overriden by
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   244
     custom TestResult subclasses."
303
6d21e7a22412 - doRunCase: renamed to performCase:
vrany
parents: 300
diff changeset
   245
    
300
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   246
    aTestCase runCase.
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   247
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   248
    "Modified: / 02-08-2011 / 18:10:09 / cg"
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   249
    "Created: / 03-08-2011 / 14:02:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   250
!
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   251
303
6d21e7a22412 - doRunCase: renamed to performCase:
vrany
parents: 300
diff changeset
   252
runCase:aTestCase 
316
d01820e6d817 changed:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   253
    "run a testcase, catching exceptions"
d01820e6d817 changed:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   254
303
6d21e7a22412 - doRunCase: renamed to performCase:
vrany
parents: 300
diff changeset
   255
    [ 
6d21e7a22412 - doRunCase: renamed to performCase:
vrany
parents: 300
diff changeset
   256
        self performCase:aTestCase.
6d21e7a22412 - doRunCase: renamed to performCase:
vrany
parents: 300
diff changeset
   257
        self addPass:aTestCase 
6d21e7a22412 - doRunCase: renamed to performCase:
vrany
parents: 300
diff changeset
   258
    ] sunitOn:self exceptions do: [:ex | 
6d21e7a22412 - doRunCase: renamed to performCase:
vrany
parents: 300
diff changeset
   259
        ex sunitAnnounce:aTestCase toResult:self 
6d21e7a22412 - doRunCase: renamed to performCase:
vrany
parents: 300
diff changeset
   260
    ].
292
Claus Gittinger <cg@exept.de>
parents: 270
diff changeset
   261
300
570aed392231 TestResult refactoring - now it allow for more fine-grained customization
vrany
parents: 297
diff changeset
   262
    "Modified: / 03-08-2011 / 14:08:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
303
6d21e7a22412 - doRunCase: renamed to performCase:
vrany
parents: 300
diff changeset
   263
    "Modified (format): / 03-08-2011 / 17:20:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
316
d01820e6d817 changed:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   264
    "Modified: / 06-08-2011 / 09:32:32 / cg"
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
! !
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
68
9fd111438d60 category renames (lower case)
Claus Gittinger <cg@exept.de>
parents: 53
diff changeset
   267
!TestResult methodsFor:'testing'!
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
53
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   269
hasErrors
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   270
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   271
	^self errors size > 0
53
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   272
!
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   273
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   274
hasFailures
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   275
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   276
	^self failures size > 0
53
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   277
!
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   278
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
hasPassed
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   280
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   281
	^self hasErrors not and: [self hasFailures not]
53
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   282
!
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   283
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   284
isError: aTestCase
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   285
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   286
	^self errors includes: aTestCase
6
78bb1397e43d added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents: 0
diff changeset
   287
!
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
isFailure: aTestCase
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   290
	^self failures includes: aTestCase
53
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   291
!
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   292
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   293
isPassed: aTestCase
51abd9fe4db2 switch to rel3.0
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   294
104
974f57e122c1 Merge SUnit 3.1 changes
Stefan Vogel <sv@exept.de>
parents: 101
diff changeset
   295
	^self passed includes: aTestCase
6
78bb1397e43d added rerun-defect tests; fixed button enable bug
Claus Gittinger <cg@exept.de>
parents: 0
diff changeset
   296
! !
0
9365d5753f11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
14
a4a5478621e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6
diff changeset
   298
!TestResult class methodsFor:'documentation'!
a4a5478621e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6
diff changeset
   299
a4a5478621e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6
diff changeset
   300
version
316
d01820e6d817 changed:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   301
    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResult.st,v 1.27 2011-08-06 07:34:48 cg Exp $'
297
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   302
!
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   303
87eb8f911bcf changed: #exceptionInfoStringFor:in:
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
   304
version_CVS
316
d01820e6d817 changed:
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
   305
    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResult.st,v 1.27 2011-08-06 07:34:48 cg Exp $'
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   306
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   307
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   308
version_SVN
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents: 183
diff changeset
   309
    ^ '§Id: TestResult.st 205 2010-09-11 15:23:01Z vranyj1 §'
14
a4a5478621e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6
diff changeset
   310
! !