345
|
1 |
"{ Package: 'stx:goodies/sunit' }"
|
|
2 |
|
|
3 |
TestResult subclass:#TestResultStX
|
|
4 |
instanceVariableNames:''
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'SUnit-Smalltalk/X'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!TestResultStX methodsFor:'outcome'!
|
|
12 |
|
|
13 |
rememberEndTime
|
|
14 |
|
|
15 |
^outcome endTime: Timestamp now
|
|
16 |
|
|
17 |
"Created: / 16-08-2011 / 17:36:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
18 |
!
|
|
19 |
|
|
20 |
rememberException:detail
|
|
21 |
"common for failure and error:
|
|
22 |
called when a test fails. testCase is the failed
|
|
23 |
testcase, detail is platform specific object describing
|
|
24 |
the failure. Actually, on all platforms exeptt GemStone,
|
|
25 |
detail is an instance of an exception that caused the failure"
|
|
26 |
|
|
27 |
|backtrace|
|
|
28 |
|
|
29 |
((Smalltalk respondsTo:#isSmalltalkX) and:[Smalltalk isSmalltalkX]) ifTrue:[
|
|
30 |
"remember the backtrace (as string, to prevent objects from being kept forwever
|
|
31 |
from being garbage collected, the signal (i.e. the exception class) and the
|
|
32 |
exceptions message (description).
|
|
33 |
Would like to have an exceptionInfo obejct for that, but that might be hard to
|
|
34 |
get returned back into the main stream sunit package..."
|
|
35 |
|
|
36 |
backtrace := String streamContents:[:s |
|
|
37 |
|con topReached|
|
|
38 |
|
|
39 |
"could use printAllOn:s, but noone is interested in contexts above the
|
|
40 |
testcase's runtest context"
|
|
41 |
topReached := false.
|
|
42 |
con := detail suspendedContext.
|
|
43 |
[
|
|
44 |
con notNil and:[topReached not]
|
|
45 |
] whileTrue:[
|
|
46 |
con printOn:s.
|
|
47 |
s cr.
|
|
48 |
topReached := (con selector == outcome selector)
|
|
49 |
and:[con receiver == outcome].
|
|
50 |
con := con sender.
|
|
51 |
]
|
|
52 |
].
|
|
53 |
outcome exceptionDetail:(Dictionary new
|
|
54 |
at:#exception put:detail signal;
|
|
55 |
at:#description put:detail description;
|
|
56 |
at:#backtrace put:backtrace;
|
|
57 |
yourself).
|
|
58 |
^ self.
|
|
59 |
].
|
|
60 |
|
|
61 |
"add other dialect specifics here"
|
|
62 |
|
|
63 |
"Created: / 06-08-2011 / 11:29:23 / cg"
|
|
64 |
"Created: / 16-08-2011 / 17:32:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
65 |
!
|
|
66 |
|
|
67 |
rememberOutput: aString
|
|
68 |
|
|
69 |
outcome collectedOutput: aString
|
|
70 |
|
|
71 |
"Created: / 16-08-2011 / 18:18:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
72 |
!
|
|
73 |
|
|
74 |
rememberStartTime
|
|
75 |
|
|
76 |
^outcome startTime: Timestamp now
|
|
77 |
|
|
78 |
"Created: / 16-08-2011 / 17:36:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
79 |
! !
|
|
80 |
|
|
81 |
!TestResultStX methodsFor:'running'!
|
|
82 |
|
|
83 |
performCase: aTestCase
|
|
84 |
|
|
85 |
| savedStdout savedTranscript collector|
|
|
86 |
|
|
87 |
savedStdout := Stdout.
|
|
88 |
savedTranscript := Transcript.
|
|
89 |
collector := WriteStream on:(String new:100).
|
|
90 |
[
|
|
91 |
Stdout := SplittingWriteStream on:collector and: Stdout.
|
|
92 |
Transcript := SplittingWriteStream on:collector and: Transcript.
|
|
93 |
super performCase: aTestCase.
|
|
94 |
] ensure:[
|
|
95 |
Stdout := savedStdout.
|
|
96 |
Transcript := savedTranscript.
|
|
97 |
self rememberOutput: collector contents.
|
|
98 |
].
|
|
99 |
|
|
100 |
"Created: / 16-08-2011 / 18:18:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
101 |
! !
|
|
102 |
|
|
103 |
!TestResultStX class methodsFor:'documentation'!
|
|
104 |
|
|
105 |
version
|
|
106 |
^ '$Header: /cvs/stx/stx/goodies/sunit/TestResultStX.st,v 1.1 2011-08-16 17:54:09 vrany Exp $'
|
|
107 |
!
|
|
108 |
|
|
109 |
version_CVS
|
|
110 |
^ '$Header: /cvs/stx/stx/goodies/sunit/TestResultStX.st,v 1.1 2011-08-16 17:54:09 vrany Exp $'
|
|
111 |
! !
|