TestResultStX.st
author Stefan Vogel <sv@exept.de>
Tue, 23 Apr 2013 12:33:43 +0200
changeset 577 3dea1e941af7
parent 571 d5a1ac6d1743
child 580 d86ef51e98ab
permissions -rw-r--r--
class: TestResource added: #safeTearDown changed: #makeAvailable Take care of AbortOperationRequest being raised in Debugger in tearDown after an errornous test case.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
345
abd1f2918992 initial checkin
vrany
parents:
diff changeset
     1
"{ Package: 'stx:goodies/sunit' }"
abd1f2918992 initial checkin
vrany
parents:
diff changeset
     2
abd1f2918992 initial checkin
vrany
parents:
diff changeset
     3
TestResult subclass:#TestResultStX
493
2469037a625d class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
     4
	instanceVariableNames:'endTime'
345
abd1f2918992 initial checkin
vrany
parents:
diff changeset
     5
	classVariableNames:''
abd1f2918992 initial checkin
vrany
parents:
diff changeset
     6
	poolDictionaries:''
abd1f2918992 initial checkin
vrany
parents:
diff changeset
     7
	category:'SUnit-Smalltalk/X'
abd1f2918992 initial checkin
vrany
parents:
diff changeset
     8
!
abd1f2918992 initial checkin
vrany
parents:
diff changeset
     9
abd1f2918992 initial checkin
vrany
parents:
diff changeset
    10
500
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    11
!TestResultStX class methodsFor:'utilities'!
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    12
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    13
sourceFilenameOfClass:aClass
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    14
    "that is ST/X specific"
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    15
    "no Smalltalk/X dialect detection needed..."
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    16
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    17
    |sourceStream testClassSourceFile|
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    18
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    19
    sourceStream := aClass sourceStream.
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    20
    sourceStream notNil ifTrue:[
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    21
        [
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    22
            sourceStream := sourceStream stream.
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    23
            sourceStream isFileStream ifTrue:[
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    24
                testClassSourceFile := sourceStream pathName asFilename pathName.
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    25
            ].
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    26
        ] ensure:[
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    27
            sourceStream close.
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    28
        ]
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    29
    ].
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    30
    ^ testClassSourceFile
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    31
! !
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    32
479
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
    33
!TestResultStX methodsFor:'accessing'!
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
    34
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
    35
endTime
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
    36
    ^ endTime
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
    37
!
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
    38
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
    39
endTime:aTimestamp
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
    40
    "sets the overall (suite) end time"
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
    41
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
    42
    endTime := aTimestamp.
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
    43
!
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
    44
482
06dcc7ec96a5 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
    45
executionTime
06dcc7ec96a5 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
    46
    "return the execution time (in seconds). If asked before or during a run, return nil"
06dcc7ec96a5 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
    47
493
2469037a625d class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
    48
    |t1 t2|
2469037a625d class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
    49
2469037a625d class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
    50
    (t1 := self startTime) isNil ifTrue:[^ nil].
2469037a625d class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
    51
    (t2 := self endTime) isNil ifTrue:[^ nil].
2469037a625d class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
    52
    ^ t2 secondDeltaFrom: t1
482
06dcc7ec96a5 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
    53
06dcc7ec96a5 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
    54
    "
06dcc7ec96a5 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
    55
     |a b|
06dcc7ec96a5 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
    56
06dcc7ec96a5 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
    57
     a := Timestamp now.
06dcc7ec96a5 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
    58
     Delay waitForMilliseconds:567.
06dcc7ec96a5 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
    59
     b := Timestamp now.
06dcc7ec96a5 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
    60
     b - a   
06dcc7ec96a5 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
    61
    "
06dcc7ec96a5 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
    62
!
06dcc7ec96a5 added: #executionTime
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
    63
479
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
    64
startTime
493
2469037a625d class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
    65
    ^ timestamp
479
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
    66
!
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
    67
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
    68
startTime:aTimestamp
493
2469037a625d class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
    69
    "sets the overall (suite) start time"
479
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
    70
493
2469037a625d class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
    71
    timestamp := aTimestamp.
479
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
    72
! !
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
    73
345
abd1f2918992 initial checkin
vrany
parents:
diff changeset
    74
!TestResultStX methodsFor:'outcome'!
abd1f2918992 initial checkin
vrany
parents:
diff changeset
    75
500
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    76
printLineForContextForJavaCompatibleStackTrace:con on:aStream
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    77
    "why in java-backtrace format?
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    78
     Because then jenkins will be able to extract sourcefile and linenumber
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    79
     and generate links in the report page.
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    80
     I am not willing to write another plugin for this - using junit compatible format"
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    81
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    82
    |cls classSourceFile method s lineNumberOfMethod lineNumberInFile relPath|
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    83
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    84
    "/ used to be:
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    85
    "/ con printOn:aStream.
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    86
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    87
    "/ be careful: some tests generate methods on the fly, which are unbound!!
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    88
    "/ or even (javascript/other languages) may not have a method at all!!!!
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    89
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    90
    con fixAllLineNumbers.
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    91
    (method := con method) notNil ifTrue:[
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    92
        cls := method mclass.
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    93
        cls notNil ifTrue:[
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    94
            relPath := cls package copyReplaceAll:$: with:$/.
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    95
            relPath := relPath copyReplaceAll:$\ with:$/.
505
f624d7b45d5e class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
    96
            relPath := (relPath asFilename construct:cls theNonMetaclass classFilename) name.
508
c6352c44c013 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 505
diff changeset
    97
            classSourceFile := relPath.
500
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    98
526
9988390f9282 lastState fixes
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
    99
            classSourceFile := Smalltalk getPackageFileName:relPath.
9988390f9282 lastState fixes
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   100
            classSourceFile isNil ifTrue:[    
9988390f9282 lastState fixes
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   101
                classSourceFile := self class sourceFilenameOfClass:cls.
9988390f9282 lastState fixes
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   102
            ].
500
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   103
            classSourceFile notNil ifTrue:[
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   104
                method sourcePosition notNil ifTrue:[
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   105
                    "/ sigh - we have the lineNumber within the method,
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   106
                    "/ and the characterPosition of the method's start.
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   107
                    "/ need to calculate the absolute lineNumber in the file
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   108
                    s := LineNumberReadStream on:(classSourceFile asFilename readStream).
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   109
                    [
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   110
                        [s position < method sourcePosition] whileTrue:[
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   111
                            s nextLine
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   112
                        ].
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   113
                        lineNumberOfMethod := s lineNumber.
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   114
                    ] ensure:[
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   115
                        s close.
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   116
                    ].
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   117
                ]
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   118
            ]
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   119
        ].
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   120
    ].
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   121
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   122
    "/ output something (will not generate a ref to the source file)
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   123
    aStream nextPutAll:('%1 >> %2 [%3]' 
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   124
                            bindWith: (con receiverPrintString)
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   125
                            with: (con selector)
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   126
                            with: (con lineNumber) ).
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   127
526
9988390f9282 lastState fixes
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   128
    relPath notNil ifTrue:[
500
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   129
        lineNumberOfMethod notNil ifTrue:[
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   130
            lineNumberInFile := lineNumberOfMethod + con lineNumber - 1.
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   131
            aStream nextPutAll:(' (%1:%2)'
526
9988390f9282 lastState fixes
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   132
                                bindWith: relPath
500
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   133
                                with: lineNumberInFile)
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   134
        ] ifFalse:[
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   135
            aStream nextPutAll:(' (%1)'
526
9988390f9282 lastState fixes
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   136
                                bindWith: relPath)
500
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   137
        ].
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   138
    ].
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   139
    aStream cr.
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   140
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   141
    "Modified: / 05-08-2012 / 12:00:00 / cg"
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   142
!
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   143
345
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   144
rememberEndTime
479
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
   145
    "remembers the endTime of the current test (in outcome)"
345
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   146
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   147
    ^outcome endTime: Timestamp now
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   148
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   149
    "Created: / 16-08-2011 / 17:36:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   150
!
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   151
505
f624d7b45d5e class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
   152
rememberException:ex
345
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   153
    "common for failure and error:
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   154
     called when a test fails. testCase is the failed 
505
f624d7b45d5e class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
   155
     testcase, ex is platform specific object describing 
345
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   156
     the failure. Actually, on all platforms exeptt GemStone, 
505
f624d7b45d5e class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
   157
     ex is an instance of an exception that caused the failure"
345
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   158
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   159
    |backtrace|
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   160
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   161
    ((Smalltalk respondsTo:#isSmalltalkX) and:[Smalltalk isSmalltalkX]) ifTrue:[
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   162
        "remember the backtrace (as string, to prevent objects from being kept forwever
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   163
         from being garbage collected, the signal (i.e. the exception class) and the
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   164
         exceptions message (description).
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   165
         Would like to have an exceptionInfo obejct for that, but that might be hard to 
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   166
         get returned back into the main stream sunit package..."
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   167
        
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   168
        backtrace := String streamContents:[:s |
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   169
                        |con topReached|
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   170
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   171
                        "could use printAllOn:s, but noone is interested in contexts above the
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   172
                         testcase's runtest context"
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   173
                        topReached := false.
505
f624d7b45d5e class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
   174
                        con := ex suspendedContext.
345
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   175
                        [ 
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   176
                            con notNil and:[topReached not]
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   177
                        ] whileTrue:[
500
b097ce6e7e84 class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   178
                            self printLineForContextForJavaCompatibleStackTrace:con on:s.
345
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   179
                            topReached := (con selector == outcome selector)
465
0297ec178c9f changed: #rememberException:
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
   180
                                          and:[con receiver == outcome
0297ec178c9f changed: #rememberException:
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
   181
                                               or:[ con receiver == outcome testCase ]].
345
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   182
                            con := con sender.
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   183
                        ]
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   184
                     ].
465
0297ec178c9f changed: #rememberException:
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
   185
345
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   186
        outcome exceptionDetail:(Dictionary new
571
d5a1ac6d1743 use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   187
                                    at:#exception put:ex creator;
505
f624d7b45d5e class: TestResultStX
Claus Gittinger <cg@exept.de>
parents: 500
diff changeset
   188
                                    at:#description put:ex description;
345
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   189
                                    at:#backtrace put:backtrace;
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   190
                                    yourself).
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   191
        ^ self.
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   192
    ].
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   193
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   194
    "add other dialect specifics here"
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   195
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   196
    "Created: / 06-08-2011 / 11:29:23 / cg"
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   197
    "Created: / 16-08-2011 / 17:32:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   198
!
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   199
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   200
rememberOutput: aString
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   201
    outcome collectedOutput: aString
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   202
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   203
    "Created: / 16-08-2011 / 18:18:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   204
!
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   205
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   206
rememberStartTime
479
b6051320c2d1 comments
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
   207
    "remembers the startTime of the current test (in outcome)"
345
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   208
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   209
    ^outcome startTime: Timestamp now
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   210
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   211
    "Created: / 16-08-2011 / 17:36:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   212
! !
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   213
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   214
!TestResultStX methodsFor:'running'!
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   215
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   216
performCase: aTestCase
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   217
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   218
    | savedStdout savedTranscript collector|
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   219
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   220
    savedStdout := Stdout.
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   221
    savedTranscript := Transcript.
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   222
    collector := WriteStream on:(String new:100).
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   223
    [
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   224
        Stdout := SplittingWriteStream on:collector and: Stdout.
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   225
        Transcript := SplittingWriteStream on:collector and: Transcript.
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   226
        super performCase: aTestCase.
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   227
    ] ensure:[
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   228
        Stdout := savedStdout.
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   229
        Transcript := savedTranscript.
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   230
        self rememberOutput: collector contents.
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   231
    ].
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   232
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   233
    "Created: / 16-08-2011 / 18:18:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   234
! !
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   235
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   236
!TestResultStX class methodsFor:'documentation'!
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   237
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   238
version
571
d5a1ac6d1743 use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   239
    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResultStX.st,v 1.10 2013-04-19 09:39:24 cg Exp $'
345
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   240
!
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   241
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   242
version_CVS
571
d5a1ac6d1743 use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   243
    ^ '$Header: /cvs/stx/stx/goodies/sunit/TestResultStX.st,v 1.10 2013-04-19 09:39:24 cg Exp $'
345
abd1f2918992 initial checkin
vrany
parents:
diff changeset
   244
! !
571
d5a1ac6d1743 use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents: 526
diff changeset
   245