author | Jan Vrany <jan.vrany@labware.com> |
Fri, 03 Dec 2021 13:24:20 +0000 | |
branch | jv |
changeset 570 | 9c47ccc9e9b5 |
parent 568 | 172c02e57616 |
permissions | -rw-r--r-- |
564
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
1 |
" |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
2 |
COPYRIGHT (c) 2020 LabWare |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
3 |
" |
67 | 4 |
"{ Package: 'stx:goodies/builder/reports' }" |
5 |
||
6 |
"{ NameSpace: Builder }" |
|
7 |
||
8 |
ReportFormat subclass:#TestReportFormat |
|
9 |
instanceVariableNames:'' |
|
10 |
classVariableNames:'' |
|
11 |
poolDictionaries:'' |
|
12 |
category:'Builder-Reports-Formats' |
|
13 |
! |
|
14 |
||
15 |
TestReportFormat subclass:#JUnit |
|
104
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
16 |
instanceVariableNames:'position failures errors skipped startTime stopTime' |
67 | 17 |
classVariableNames:'' |
18 |
poolDictionaries:'' |
|
19 |
privateIn:TestReportFormat |
|
20 |
! |
|
21 |
||
22 |
TestReportFormat subclass:#PerfPublisher |
|
23 |
instanceVariableNames:'' |
|
24 |
classVariableNames:'' |
|
25 |
poolDictionaries:'' |
|
26 |
privateIn:TestReportFormat |
|
27 |
! |
|
28 |
||
29 |
TestReportFormat subclass:#PythonUnittest |
|
30 |
instanceVariableNames:'index' |
|
31 |
classVariableNames:'' |
|
32 |
poolDictionaries:'' |
|
33 |
privateIn:TestReportFormat |
|
34 |
! |
|
35 |
||
36 |
TestReportFormat subclass:#TAP |
|
37 |
instanceVariableNames:'index' |
|
38 |
classVariableNames:'' |
|
39 |
poolDictionaries:'' |
|
40 |
privateIn:TestReportFormat |
|
41 |
! |
|
42 |
||
564
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
43 |
!TestReportFormat class methodsFor:'documentation'! |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
44 |
|
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
45 |
copyright |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
46 |
" |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
47 |
COPYRIGHT (c) 2020 LabWare |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
48 |
|
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
49 |
" |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
50 |
! ! |
67 | 51 |
|
52 |
!TestReportFormat class methodsFor:'testing'! |
|
53 |
||
54 |
isAbstract |
|
55 |
||
56 |
^self == TestReportFormat |
|
57 |
||
58 |
"Created: / 04-08-2011 / 11:44:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
59 |
! ! |
|
60 |
||
61 |
!TestReportFormat methodsFor:'accessing - defaults'! |
|
62 |
||
63 |
defaultFileSuffix |
|
64 |
"superclass HDReportFormat says that I am responsible to implement this method" |
|
65 |
||
66 |
^ 'xml' |
|
67 |
||
68 |
"Modified: / 04-08-2011 / 12:48:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
69 |
! ! |
|
70 |
||
71 |
!TestReportFormat methodsFor:'writing'! |
|
72 |
||
73 |
writeTestCase: testcase outcome: outcome time: time exception: exception |
|
74 |
||
75 |
| stacktrace | |
|
76 |
exception isNil ifTrue:[ |
|
77 |
stacktrace := nil. |
|
78 |
] ifFalse:[ |
|
79 |
stacktrace := |
|
80 |
(String streamContents:[:s| |
|
81 |
self writeStackTrace: exception of: testcase on: s |
|
82 |
]) |
|
83 |
]. |
|
84 |
||
85 |
^self writeTestCase: testcase outcome: outcome time: time exception: exception |
|
86 |
stacktrace: stacktrace |
|
87 |
||
88 |
"Created: / 03-08-2011 / 19:44:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
89 |
! |
|
90 |
||
91 |
writeTestCase: testcase outcome: outcome time: time exception: exception stacktrace: stacktrace |
|
92 |
||
93 |
"Write an outcome of a given test. |
|
94 |
Argumments: |
|
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
95 |
testcase....the testcase <TestCase> |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
96 |
outcome.....the testcase outcome <TestCaseOutcome> |
67 | 97 |
time........time taken to run the test in milliseconds |
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
98 |
exception...exception that caused error/failure or nil if N/A < Exception | nil > |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
99 |
backtrace...stacktrace info or nil if N/A <String | nil >" |
67 | 100 |
|
101 |
self subclassResponsibility |
|
102 |
||
103 |
"Created: / 03-08-2011 / 19:43:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
104 |
"Modified (comment): / 06-06-2014 / 00:51:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
67 | 105 |
! ! |
106 |
||
107 |
!TestReportFormat methodsFor:'writing - utilities'! |
|
108 |
||
109 |
writeContext: context on: s |
|
110 |
||
568
172c02e57616
Fix source line indicator (>>) printing in report stacktraces
Jan Vrany <jan.vrany@labware.com>
parents:
567
diff
changeset
|
111 |
| home mthd src rcvr srcFirstLineNr | |
67 | 112 |
[ |
113 |
context printOn: s. |
|
114 |
s cr. |
|
86 | 115 |
s nextPutAll:'receiver: '. context receiver printOn: s. s cr. |
296
4c26321be573
Test report: show also a bytecode for each method on the stack
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
248
diff
changeset
|
116 |
s nextPutAll:'selector: '. context selector storeOn: s. s cr. |
4c26321be573
Test report: show also a bytecode for each method on the stack
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
248
diff
changeset
|
117 |
|
564
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
118 |
rcvr := context receiver. |
565
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
119 |
|
67 | 120 |
s nextPutAll:'args: '; cr. |
565
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
121 |
self writeContextArgs: context on: s. |
296
4c26321be573
Test report: show also a bytecode for each method on the stack
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
248
diff
changeset
|
122 |
|
67 | 123 |
s nextPutAll:'vars: '; cr. |
565
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
124 |
self writeContextVars: context on: s. |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
125 |
|
564
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
126 |
s nextPutAll:'inst: '; cr. |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
127 |
rcvr class allInstVarNames keysAndValuesDo:[ :idx :eachNam | |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
128 |
self writeVariable: eachNam index: idx value: (rcvr instVarNamed: eachNam) on: s. |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
129 |
]. |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
130 |
|
296
4c26321be573
Test report: show also a bytecode for each method on the stack
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
248
diff
changeset
|
131 |
home := context methodHome. |
4c26321be573
Test report: show also a bytecode for each method on the stack
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
248
diff
changeset
|
132 |
mthd := home method. |
4c26321be573
Test report: show also a bytecode for each method on the stack
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
248
diff
changeset
|
133 |
|
564
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
134 |
(report notNil and:[report keepBytecode]) ifTrue:[ |
303 | 135 |
s nextPutAll:'bytecode: '; cr. |
136 |
mthd notNil ifTrue:[ |
|
137 |
(mthd isJavaMethod and:[mthd class ~~ JavaNativeMethod]) ifFalse:[ |
|
138 |
Decompiler decompile: mthd to: s. |
|
139 |
] ifTrue:[ |
|
140 |
(Smalltalk at: #JavaByteCodeDisassembler) notNil ifTrue:[ |
|
141 |
(Smalltalk at: #JavaByteCodeDisassembler) diassemble: mthd to: s. |
|
142 |
] ifFalse:[ |
|
143 |
s nextPutAll: ' ** no JavaByteCodeDisassembler **' |
|
144 |
]. |
|
296
4c26321be573
Test report: show also a bytecode for each method on the stack
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
248
diff
changeset
|
145 |
]. |
4c26321be573
Test report: show also a bytecode for each method on the stack
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
248
diff
changeset
|
146 |
]. |
4c26321be573
Test report: show also a bytecode for each method on the stack
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
248
diff
changeset
|
147 |
]. |
4c26321be573
Test report: show also a bytecode for each method on the stack
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
248
diff
changeset
|
148 |
|
4c26321be573
Test report: show also a bytecode for each method on the stack
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
248
diff
changeset
|
149 |
s cr. |
67 | 150 |
s nextPutAll:'source: '; cr. |
151 |
[ |
|
152 |
mthd isNil ifTrue:[ |
|
153 |
s nextPutAll: '** no source **'. s cr. s cr. |
|
154 |
^ self. |
|
155 |
]. |
|
156 |
src := mthd source. |
|
157 |
src isNil ifTrue:[ |
|
158 |
s nextPutAll: '** no source **'. s cr. s cr. |
|
159 |
^ self. |
|
160 |
]. |
|
161 |
] on: Error do:[:ex| |
|
162 |
s |
|
163 |
nextPutAll: '** error when getting source: '; |
|
164 |
nextPutAll: ex description; |
|
165 |
nextPutAll: '**'; |
|
166 |
cr; cr. |
|
167 |
^ self. |
|
168 |
]. |
|
169 |
src := src asCollectionOfLines. |
|
566
030aa8306eda
Print line numbers and at most 40 lines of source per method in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
565
diff
changeset
|
170 |
srcFirstLineNr := 1. |
030aa8306eda
Print line numbers and at most 40 lines of source per method in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
565
diff
changeset
|
171 |
src size > 40 ifTrue:[ |
030aa8306eda
Print line numbers and at most 40 lines of source per method in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
565
diff
changeset
|
172 |
| last | |
030aa8306eda
Print line numbers and at most 40 lines of source per method in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
565
diff
changeset
|
173 |
|
030aa8306eda
Print line numbers and at most 40 lines of source per method in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
565
diff
changeset
|
174 |
srcFirstLineNr := (context lineNumber - 15) max: 1. |
030aa8306eda
Print line numbers and at most 40 lines of source per method in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
565
diff
changeset
|
175 |
last := (srcFirstLineNr + 29) min: src size. |
030aa8306eda
Print line numbers and at most 40 lines of source per method in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
565
diff
changeset
|
176 |
src := src copyFrom: srcFirstLineNr to: last. |
030aa8306eda
Print line numbers and at most 40 lines of source per method in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
565
diff
changeset
|
177 |
]. |
568
172c02e57616
Fix source line indicator (>>) printing in report stacktraces
Jan Vrany <jan.vrany@labware.com>
parents:
567
diff
changeset
|
178 |
src keysAndValuesDo:[:i :line | |
172c02e57616
Fix source line indicator (>>) printing in report stacktraces
Jan Vrany <jan.vrany@labware.com>
parents:
567
diff
changeset
|
179 |
| lineNo | |
172c02e57616
Fix source line indicator (>>) printing in report stacktraces
Jan Vrany <jan.vrany@labware.com>
parents:
567
diff
changeset
|
180 |
|
172c02e57616
Fix source line indicator (>>) printing in report stacktraces
Jan Vrany <jan.vrany@labware.com>
parents:
567
diff
changeset
|
181 |
lineNo := i + srcFirstLineNr - 1. |
172c02e57616
Fix source line indicator (>>) printing in report stacktraces
Jan Vrany <jan.vrany@labware.com>
parents:
567
diff
changeset
|
182 |
|
566
030aa8306eda
Print line numbers and at most 40 lines of source per method in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
565
diff
changeset
|
183 |
s nextPutAll:' '. |
568
172c02e57616
Fix source line indicator (>>) printing in report stacktraces
Jan Vrany <jan.vrany@labware.com>
parents:
567
diff
changeset
|
184 |
lineNo printOn: s leftPaddedTo:4. |
172c02e57616
Fix source line indicator (>>) printing in report stacktraces
Jan Vrany <jan.vrany@labware.com>
parents:
567
diff
changeset
|
185 |
lineNo == context lineNumber ifTrue:[ |
67 | 186 |
s nextPutAll:'>> '. |
187 |
] ifFalse:[ |
|
188 |
s nextPutAll:' '. |
|
189 |
]. |
|
190 |
s nextPutAll: line; cr. |
|
191 |
]. |
|
192 |
s cr. |
|
193 |
] on: Error do:[:ex| |
|
194 |
s cr; |
|
567
8d386d0a4bfb
Try to dump 'basic' stacktrace if there's an error printing 'full' stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
566
diff
changeset
|
195 |
nextPutAll:'!!!!!!ERROR WHEN GETTING FULL STACK TRACE!!!!!!'; cr; |
8d386d0a4bfb
Try to dump 'basic' stacktrace if there's an error printing 'full' stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
566
diff
changeset
|
196 |
nextPutAll: ex description; cr. |
8d386d0a4bfb
Try to dump 'basic' stacktrace if there's an error printing 'full' stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
566
diff
changeset
|
197 |
[ |
8d386d0a4bfb
Try to dump 'basic' stacktrace if there's an error printing 'full' stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
566
diff
changeset
|
198 |
ex suspendedContext fullPrintAllOn: s |
8d386d0a4bfb
Try to dump 'basic' stacktrace if there's an error printing 'full' stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
566
diff
changeset
|
199 |
] on: Error do:[:ex | |
8d386d0a4bfb
Try to dump 'basic' stacktrace if there's an error printing 'full' stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
566
diff
changeset
|
200 |
s cr; nextPutAll:'!!!!!!ERROR WHEN GETTING BASIC STACK TRACE!!!!!!'; cr. |
8d386d0a4bfb
Try to dump 'basic' stacktrace if there's an error printing 'full' stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
566
diff
changeset
|
201 |
] |
296
4c26321be573
Test report: show also a bytecode for each method on the stack
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
248
diff
changeset
|
202 |
]. |
4c26321be573
Test report: show also a bytecode for each method on the stack
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
248
diff
changeset
|
203 |
|
4c26321be573
Test report: show also a bytecode for each method on the stack
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
248
diff
changeset
|
204 |
" |
564
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
205 |
String streamContents:[ :s | Builder::TestReportFormat new writeContext: thisContext on: s ] |
567
8d386d0a4bfb
Try to dump 'basic' stacktrace if there's an error printing 'full' stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
566
diff
changeset
|
206 |
|
8d386d0a4bfb
Try to dump 'basic' stacktrace if there's an error printing 'full' stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
566
diff
changeset
|
207 |
String streamContents:[ :s | |
8d386d0a4bfb
Try to dump 'basic' stacktrace if there's an error printing 'full' stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
566
diff
changeset
|
208 |
[ |
8d386d0a4bfb
Try to dump 'basic' stacktrace if there's an error printing 'full' stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
566
diff
changeset
|
209 |
TestFailure sunitSignalWith: 'XXX' |
8d386d0a4bfb
Try to dump 'basic' stacktrace if there's an error printing 'full' stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
566
diff
changeset
|
210 |
] on: TestFailure do:[:ex | |
8d386d0a4bfb
Try to dump 'basic' stacktrace if there's an error printing 'full' stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
566
diff
changeset
|
211 |
Builder::TestReportFormat new writeContext: ex suspendedContext on: s |
8d386d0a4bfb
Try to dump 'basic' stacktrace if there's an error printing 'full' stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
566
diff
changeset
|
212 |
] |
8d386d0a4bfb
Try to dump 'basic' stacktrace if there's an error printing 'full' stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
566
diff
changeset
|
213 |
]. |
8d386d0a4bfb
Try to dump 'basic' stacktrace if there's an error printing 'full' stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
566
diff
changeset
|
214 |
|
296
4c26321be573
Test report: show also a bytecode for each method on the stack
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
248
diff
changeset
|
215 |
" |
67 | 216 |
|
217 |
"Created: / 03-08-2011 / 14:53:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
303 | 218 |
"Modified: / 15-03-2016 / 14:34:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
568
172c02e57616
Fix source line indicator (>>) printing in report stacktraces
Jan Vrany <jan.vrany@labware.com>
parents:
567
diff
changeset
|
219 |
"Modified (format): / 29-06-2020 / 22:20:44 / Jan Vrany <jan.vrany@labware.com>" |
565
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
220 |
! |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
221 |
|
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
222 |
writeContextArgs: context on: s |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
223 |
| current | |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
224 |
|
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
225 |
current := context. |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
226 |
[ current notNil ] whileTrue:[ |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
227 |
| args names | |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
228 |
|
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
229 |
args := current args. |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
230 |
names := current argAndVarNames. |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
231 |
|
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
232 |
args keysAndValuesDo:[:idx :eachArg | |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
233 |
self writeVariable: (names at: idx ifAbsent:['???']) index: idx value: eachArg on: s. |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
234 |
]. |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
235 |
current := current home. |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
236 |
current notNil ifTrue:[ s cr ]. |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
237 |
] |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
238 |
|
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
239 |
"Created: / 02-06-2020 / 11:33:55 / Jan Vrany <jan.vrany@labware.com>" |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
240 |
! |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
241 |
|
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
242 |
writeContextVars: context on: s |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
243 |
| current | |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
244 |
|
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
245 |
current := context. |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
246 |
[ current notNil ] whileTrue:[ |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
247 |
| vars names nargs | |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
248 |
|
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
249 |
vars := current vars. |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
250 |
names := current argAndVarNames. |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
251 |
nargs := current numArgs. |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
252 |
|
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
253 |
vars keysAndValuesDo:[:idx :eachArg | |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
254 |
self writeVariable: (names at: idx + nargs ifAbsent:['???']) index: idx value: eachArg on: s. |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
255 |
]. |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
256 |
current := current home. |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
257 |
current notNil ifTrue:[ s cr ]. |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
258 |
] |
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
259 |
|
80afdfe990f9
Print arguments and locals from home contexts as well in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
564
diff
changeset
|
260 |
"Created: / 02-06-2020 / 11:36:29 / Jan Vrany <jan.vrany@labware.com>" |
67 | 261 |
! |
262 |
||
263 |
writeStackTrace:err of:aTestCase on: str |
|
264 |
||
303 | 265 |
| context | |
67 | 266 |
|
267 |
context := err signalerContext. |
|
91 | 268 |
|
269 |
[ context notNil ] whileTrue:[ |
|
270 |
self writeContext: context on: str. |
|
271 |
str cr; cr. |
|
272 |
||
564
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
273 |
(context receiver notNil and:[context receiver == aTestCase ]) ifTrue:[ |
91 | 274 |
context selector == aTestCase selector ifTrue:[ ^ self ]. |
275 |
context selector == #setUp ifTrue:[ ^ self ]. |
|
276 |
]. |
|
277 |
context := context sender. |
|
564
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
278 |
]. |
91 | 279 |
|
564
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
280 |
" |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
281 |
[ Error signal ] on: Error do:[:ex| String streamContents:[ :s | Builder::TestReportFormat new writeStackTrace: ex of: nil on: s ] ] |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
282 |
" |
67 | 283 |
|
284 |
"Created: / 03-08-2011 / 14:53:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
303 | 285 |
"Modified: / 15-03-2016 / 14:33:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
564
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
286 |
"Modified: / 02-06-2020 / 11:03:30 / Jan Vrany <jan.vrany@labware.com>" |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
287 |
! |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
288 |
|
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
289 |
writeVariable: name index: index value: value on: s |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
290 |
s nextPutAll:' '. |
566
030aa8306eda
Print line numbers and at most 40 lines of source per method in stacktrace
Jan Vrany <jan.vrany@labware.com>
parents:
565
diff
changeset
|
291 |
index printOn: s leftPaddedTo:4 . s space. |
564
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
292 |
name printOn: s paddedTo:12. s nextPutAll:': '. |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
293 |
value isString ifTrue:[ |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
294 |
value storeOn: s |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
295 |
] ifFalse:[ |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
296 |
value printOn: s. |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
297 |
]. |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
298 |
s cr. |
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
299 |
|
089cc2fa6c6c
Print all instance variables in failed test stack trace
Jan Vrany <jan.vrany@labware.com>
parents:
334
diff
changeset
|
300 |
"Created: / 02-06-2020 / 10:53:08 / Jan Vrany <jan.vrany@labware.com>" |
67 | 301 |
! ! |
302 |
||
303 |
!TestReportFormat::JUnit class methodsFor:'accessing'! |
|
304 |
||
305 |
symbolicNames |
|
306 |
^ #( #junit #junit40 ) |
|
307 |
||
308 |
"Created: / 04-08-2011 / 11:45:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
309 |
! ! |
|
310 |
||
311 |
!TestReportFormat::JUnit class methodsFor:'documentation'! |
|
312 |
||
313 |
version_SVN |
|
191
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
314 |
^ '$Id$' |
67 | 315 |
! ! |
316 |
||
317 |
!TestReportFormat::JUnit methodsFor:'initialization'! |
|
318 |
||
319 |
initialize |
|
320 |
||
321 |
super initialize. |
|
322 |
errors := 0. |
|
323 |
failures := 0. |
|
104
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
324 |
skipped := 0. |
67 | 325 |
|
326 |
"Created: / 03-08-2011 / 15:26:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
104
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
327 |
"Modified: / 21-11-2012 / 15:33:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
67 | 328 |
! ! |
329 |
||
330 |
!TestReportFormat::JUnit methodsFor:'writing'! |
|
331 |
||
332 |
writeFooter |
|
333 |
stopTime := OperatingSystem getMillisecondTime. |
|
334 |
stream |
|
335 |
tab; |
|
336 |
nextPutAll:'<system-out><!![CDATA[]]></system-out>'; |
|
337 |
nextPut:Character lf. |
|
338 |
stream |
|
339 |
tab; |
|
340 |
nextPutAll:'<system-err><!![CDATA[]]></system-err>'; |
|
341 |
nextPut:Character lf. |
|
342 |
stream nextPutAll:'</testsuite>'. |
|
343 |
stream stream position:position. |
|
344 |
stream |
|
345 |
nextPutAll:' failures="'; |
|
346 |
print:failures; |
|
347 |
nextPutAll:'" errors="'; |
|
348 |
print:errors; |
|
104
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
349 |
nextPutAll:'" skipped="'; |
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
350 |
print:skipped; |
67 | 351 |
nextPutAll:'" time="'; |
352 |
print:(Time milliseconds:stopTime since:startTime) / 1000.0; |
|
353 |
nextPutAll:'">'. |
|
354 |
stream close. |
|
355 |
||
356 |
"Created: / 03-08-2011 / 14:22:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
104
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
357 |
"Modified: / 21-11-2012 / 15:34:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
67 | 358 |
! |
359 |
||
360 |
writeHeader |
|
361 |
stream |
|
362 |
nextPutAll:'<?xml version="1.0" encoding="UTF-8"?>'; |
|
363 |
nextPut:Character lf. |
|
364 |
stream |
|
365 |
nextPutAll:'<testsuite name="'; |
|
366 |
nextPutAll:(Report encode:report name); |
|
367 |
nextPutAll:'" tests="'; |
|
368 |
print:report suite testCount; |
|
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
369 |
nextPutAll:('" hostname="%1"' bindWith:OperatingSystem getHostName); |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
370 |
nextPutAll:'>'. |
67 | 371 |
"Now this is ugly. We want to update the time and the number of failures and errors, but still at the same time stream a valid XML. So remember this position and add some whitespace, that we can fill later." |
372 |
position := stream stream position - 1. |
|
373 |
stream |
|
374 |
nextPutAll:(String new:100 withAll:$ ); |
|
375 |
nextPut:Character lf. |
|
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
376 |
stream |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
377 |
nextPutLine: ' <properties>'; |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
378 |
nextPutLine: ' <property name="programmingLanguage" value="Smalltalk" />'; |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
379 |
nextPutLine: ' <property name="smalltalk.vendor" value="exept Software AG" />'; |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
380 |
nextPutLine: ' <property name="smalltalk.compiler" value="Smalltalk/X" />'; |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
381 |
nextPutLine:(' <property name="smalltalk.version" value="%1" />'bindWith:Smalltalk versionString); |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
382 |
nextPutLine:(' <property name="os.name" value="%1" />' bindWith:OperatingSystem osName); |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
383 |
nextPutLine:(' <property name="os.arch" value="%1" />' bindWith:OperatingSystem getCPUType); |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
384 |
nextPutLine:(' <property name="user.name" value="%1" />' bindWith:OperatingSystem getLoginName); |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
385 |
nextPutLine:(' <property name="user.language" value="%1" />' bindWith:Smalltalk language). |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
386 |
"/ stream |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
387 |
"/ nextPutLine:(' <property name="smalltalk.libbasic.version" value="%1" />'bindWith:stx_libbasic versionString). |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
388 |
stream |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
389 |
nextPutLine: ' </properties>'. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
390 |
|
67 | 391 |
startTime := OperatingSystem getMillisecondTime. |
392 |
||
393 |
"Created: / 03-08-2011 / 19:14:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
394 |
"Modified: / 06-06-2014 / 01:14:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
67 | 395 |
! |
396 |
||
397 |
writeTestCase:testcase outcome:outcome time:time exception: exception stacktrace:stacktrace |
|
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
398 |
| result | |
67 | 399 |
|
319 | 400 |
outcome result == TestResult statePass ifTrue:[ |
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
401 |
result := #pass. |
319 | 402 |
] ifFalse:[ |
403 |
outcome result == TestResult stateFail ifTrue:[ |
|
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
404 |
result := #failure. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
405 |
failures := failures + 1 |
319 | 406 |
] ifFalse:[ |
407 |
outcome result == TestResult stateError ifTrue:[ |
|
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
408 |
result := #error. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
409 |
errors := errors + 1. |
319 | 410 |
] ifFalse:[ |
411 |
outcome result == TestResult stateSkip ifTrue:[ |
|
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
412 |
result := #skip. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
413 |
skipped := skipped + 1 |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
414 |
] ifFalse:[ |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
415 |
self error: 'Invalid test result'. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
416 |
] |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
417 |
]. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
418 |
]. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
419 |
]. |
67 | 420 |
|
319 | 421 |
stream tab; |
422 |
nextPutAll: '<testcase classname="'; |
|
423 |
nextPutAll: (self encode: testcase nameForHDTestReport); |
|
424 |
nextPutAll: '" name="'; |
|
425 |
nextPutAll: (self encode: testcase selectorForHDTestReport); |
|
67 | 426 |
nextPutAll: '" time="'; print: (time ? 0) / 1000.0; nextPutAll: '">'; cr. |
427 |
||
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
428 |
result == #skip ifTrue:[ |
104
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
429 |
stream tab; tab; nextPutAll: '<skipped/>'. |
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
430 |
] ifFalse:[ |
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
431 |
result ~~ #pass ifTrue:[ |
104
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
432 |
| type message | |
67 | 433 |
|
104
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
434 |
exception isNil ifTrue:[ |
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
435 |
type := 'unknown exception'. |
319 | 436 |
message := 'unknown exception occurred (no exception details available)' |
104
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
437 |
] ifFalse:[ |
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
438 |
type := exception class name. |
334
a7f6c7bc62a8
Test report: print system identification in stacktrace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
323
diff
changeset
|
439 |
message := exception messageText notNil ifTrue:[ exception description ] ifFalse:[ 'no exception']. |
104
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
440 |
]. |
319 | 441 |
|
67 | 442 |
|
104
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
443 |
stream tab; tab; |
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
444 |
nextPut:$<; nextPutAll: result; |
104
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
445 |
nextPutAll:' type="'; |
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
446 |
nextPutAll:(self encode:type); |
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
447 |
nextPutAll:'" message="'; |
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
448 |
nextPutAll:(self encode: message); |
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
449 |
nextPutAll:'"><!![CDATA['; cr. |
334
a7f6c7bc62a8
Test report: print system identification in stacktrace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
323
diff
changeset
|
450 |
"/ Write system identification here so one can tell on which system |
a7f6c7bc62a8
Test report: print system identification in stacktrace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
323
diff
changeset
|
451 |
"/ it failed. Jenkins JUnit plugin infortunately does not show this |
a7f6c7bc62a8
Test report: print system identification in stacktrace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
323
diff
changeset
|
452 |
"/ info in it's own UI |
a7f6c7bc62a8
Test report: print system identification in stacktrace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
323
diff
changeset
|
453 |
self writeCDATA: ('Hostname: ' , OperatingSystem getHostName , Character cr). |
a7f6c7bc62a8
Test report: print system identification in stacktrace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
323
diff
changeset
|
454 |
self writeCDATA: ('OS: ' , OperatingSystem osName , Character cr). |
a7f6c7bc62a8
Test report: print system identification in stacktrace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
323
diff
changeset
|
455 |
self writeCDATA: ('Arch: ' , OperatingSystem getCPUType , Character cr, Character cr). |
a7f6c7bc62a8
Test report: print system identification in stacktrace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
323
diff
changeset
|
456 |
|
191
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
457 |
self writeCDATA: (stacktrace ? 'stacktrace not available'). |
104
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
458 |
stream |
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
459 |
nextPutAll:']]></'; nextPutAll: result; nextPutAll:'>'; |
104
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
460 |
nextPut:Character lf |
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
461 |
]. |
67 | 462 |
]. |
242
d9479f1e61fa
Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
235
diff
changeset
|
463 |
report keepStdout ifTrue:[ |
d9479f1e61fa
Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
235
diff
changeset
|
464 |
outcome collectedOutput notEmptyOrNil ifTrue:[ |
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
465 |
stream nextPutAll:' <system-out><!![CDATA['; cr. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
466 |
self writeCDATA: outcome collectedOutput. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
467 |
stream nextPutAll:']]> </system-out>'; cr. |
319 | 468 |
]. |
242
d9479f1e61fa
Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
235
diff
changeset
|
469 |
]. |
104
7b1b26108f1f
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
91
diff
changeset
|
470 |
|
319 | 471 |
stream tab; |
67 | 472 |
nextPutAll: '</testcase>'; cr. |
473 |
||
474 |
||
475 |
stream flush |
|
476 |
||
477 |
"Created: / 03-08-2011 / 19:42:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
334
a7f6c7bc62a8
Test report: print system identification in stacktrace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
323
diff
changeset
|
478 |
"Modified: / 19-08-2017 / 14:38:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
191
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
479 |
! ! |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
480 |
|
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
481 |
!TestReportFormat::JUnit methodsFor:'writing - utilities'! |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
482 |
|
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
483 |
writeCDATA: string |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
484 |
| start stop | |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
485 |
|
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
486 |
start := 1. |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
487 |
stop := start. |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
488 |
[ (stop := (string indexOf: $] startingAt: stop)) ~~ 0 ] whileTrue:[ |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
489 |
((stop < (string size - 1)) |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
490 |
and:[(string at: stop + 1) == $] |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
491 |
and:[(string at: stop + 2) == $>]]) ifTrue:[ |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
492 |
" Okay, found CDATA end token " |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
493 |
stream nextPutAll: string startingAt: start to: stop + 1. |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
494 |
stream nextPutAll: ']]><!![CDATA[>'. |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
495 |
start := stop := stop + 3. |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
496 |
] ifFalse:[ |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
497 |
stop := stop + 1. |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
498 |
]. |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
499 |
]. |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
500 |
start < string size ifTrue:[ |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
501 |
stream nextPutAll: string startingAt: start to: string size. |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
502 |
]. |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
503 |
|
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
504 |
" |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
505 |
String streamContents:[:s | Builder::TestReportFormat::JUnit new report: nil stream: s; writeCDATA:'ABCD'] |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
506 |
String streamContents:[:s | Builder::TestReportFormat::JUnit new report: nil stream: s; writeCDATA:']]]]'] |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
507 |
String streamContents:[:s | Builder::TestReportFormat::JUnit new report: nil stream: s; writeCDATA:'Some <[CDATA[ CDATA ]]> Some Text and stray terminator ]]> here'] |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
508 |
" |
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
509 |
|
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
510 |
"Created: / 05-07-2013 / 16:54:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
67 | 511 |
! ! |
512 |
||
513 |
!TestReportFormat::PerfPublisher class methodsFor:'accessing'! |
|
514 |
||
515 |
symbolicNames |
|
516 |
"Returns a collection of symbolic names for this format" |
|
517 |
||
518 |
^ #(perfPublisher) |
|
519 |
||
520 |
"Modified: / 04-08-2011 / 11:52:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
521 |
! ! |
|
522 |
||
523 |
!TestReportFormat::PerfPublisher class methodsFor:'documentation'! |
|
524 |
||
525 |
version_SVN |
|
191
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
526 |
^ '$Id$' |
67 | 527 |
! ! |
528 |
||
529 |
!TestReportFormat::PerfPublisher methodsFor:'writing'! |
|
530 |
||
531 |
writeFooter |
|
532 |
||
533 |
stream nextPutLine: '</report>' |
|
534 |
||
535 |
"Modified: / 03-08-2011 / 20:12:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
536 |
! |
|
537 |
||
538 |
writeHeader |
|
539 |
||
540 |
|reportName reportCategory testClass| |
|
541 |
||
542 |
reportName := report suite name. |
|
543 |
reportCategory := 'uncategorized'. "/ it is a required attribute; so what should we use ? |
|
544 |
||
545 |
(testClass := Smalltalk at:reportName asSymbol) isBehavior ifTrue:[ |
|
546 |
reportCategory := testClass category. "/ at least, something to show |
|
547 |
]. |
|
548 |
||
549 |
stream |
|
550 |
nextPutLine: '<?xml version="1.0"?>'; |
|
551 |
nextPutLine:('<report name="%1" categ="%2">' bindWith:reportName with:reportCategory); |
|
552 |
nextPutLine:(' <start>'); |
|
553 |
nextPutLine:(' <date format="YYYYMMDD" val="%1" />' bindWith:(Date today printStringFormat:'%y%m%d')); |
|
554 |
nextPutLine:(' <time format="HHMMSS" val="%1" />' bindWith:(Time now printStringFormat:'%h%m%s')); |
|
555 |
nextPutLine:(' </start>'). |
|
556 |
||
557 |
"Modified: / 03-08-2011 / 20:12:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
558 |
! |
|
559 |
||
560 |
writeTestCase:testcase outcome:outcome time:time exception:exception stacktrace:stacktrace |
|
561 |
||
562 |
" |
|
563 |
Example: |
|
564 |
<test |
|
565 |
name='test_format_link_not_in_repos_with_line' |
|
566 |
executed='exec-status' |
|
567 |
<result> |
|
568 |
<success passed='result-status' state='result-state'/> |
|
569 |
<errorlog><!![CDATA[EXEMPLE OF ERROR LOG]]></errorlog> |
|
570 |
</result> |
|
571 |
</test> |
|
572 |
" |
|
573 |
||
574 |
|testClassName executionTime testName testDescription |
|
575 |
successPassed successState exceptionInfo |
|
576 |
compilerName compilerVersion compilerConfiguration compilerVersionDate |
|
577 |
timeUnit timeMeasure |
|
578 |
sysInfo osType osVersion cpuType| |
|
579 |
||
580 |
testClassName := testcase printString. |
|
581 |
testName := testcase selector. |
|
582 |
||
583 |
"most tests do not know, and return nil here!!" |
|
584 |
executionTime := time. "/ millis |
|
585 |
testDescription := '%1-%2' bindWith:testClassName with:testName. |
|
586 |
||
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
587 |
successPassed := (outcome result == TestResult statePass) ifTrue:['yes'] ifFalse:['no']. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
588 |
(outcome result ~~ TestResult statePass) ifTrue:[ |
67 | 589 |
exceptionInfo := stacktrace ? 'No stacktrace available'. |
590 |
]. |
|
591 |
||
592 |
successState := 'foo'. |
|
593 |
||
594 |
"/ caveat: the following needs to be made dialect-specific |
|
595 |
compilerName := 'Smalltalk/X'. |
|
596 |
compilerVersion := Smalltalk versionString. |
|
597 |
compilerConfiguration := Smalltalk configuration. |
|
598 |
compilerVersionDate := Smalltalk versionDate. |
|
599 |
||
600 |
sysInfo := OperatingSystem getSystemInfo. |
|
601 |
osType := (sysInfo at:#osType ifAbsent:'?'). |
|
602 |
osVersion := (sysInfo at:#release ifAbsent:'?'). |
|
603 |
||
604 |
cpuType := (sysInfo at:#cpuType ifAbsent:'?'). |
|
605 |
"/ cpuSpeed := (sysInfo at:#cpuSpeed ifAbsent:'?'). |
|
606 |
||
607 |
timeUnit := 'ms'. |
|
608 |
timeMeasure := executionTime. |
|
609 |
||
610 |
stream |
|
611 |
nextPutLine:('<test name="%1" executed="yes">' bindWith: testName); |
|
612 |
nextPutLine:(' <description><!![CDATA[%1]]></description>' bindWith: testDescription); |
|
613 |
nextPutLine:' <platform>'; |
|
614 |
nextPutLine:' <os>'; |
|
615 |
nextPutLine:(' <type><!![CDATA[%1]]></type>' bindWith:osType); |
|
616 |
nextPutLine:(' <version><!![CDATA[%1]]></version>' bindWith:osVersion); |
|
617 |
nextPutLine:' </os>'; |
|
618 |
nextPutLine:(' <processor arch="%1">' bindWith:cpuType); |
|
619 |
"/ nextPutLine:(' <frequency> unit="Mhz" cpufreq="%1" />' bindWith:cpuSpeed); |
|
620 |
nextPutLine:' </processor>'; |
|
621 |
nextPutLine:(' <compiler name="%1" version="%2" versiondate="%3" configuration="%4" />' |
|
622 |
bindWith:compilerName with:compilerVersion |
|
623 |
with:compilerVersionDate with:compilerConfiguration); |
|
624 |
"/ nextPutLine:' <environment />'; |
|
625 |
nextPutLine:' </platform>'; |
|
626 |
nextPutLine:' <result>'; |
|
627 |
nextPutLine:(' <success passed="%1" state="100" />' |
|
628 |
bindWith:successPassed with:successState); |
|
629 |
"/ cg: in the perfPublisher documentation, I found "mesure". |
|
630 |
"/ I am not sure, if that was a typo, or is actually what is expected... |
|
631 |
"/ to be on the save side, I generate both a mesure and a measure attribute, |
|
632 |
"/ so it will work, even if they ever fix perfPublisher's xml parser. |
|
633 |
nextPutLine:(' <executiontime unit="%1" mesure="%2" measure="%2" isRelevant="yes" />' |
|
634 |
bindWith:timeUnit with:timeMeasure). |
|
635 |
||
636 |
exceptionInfo notNil ifTrue:[ |
|
637 |
stream |
|
638 |
nextPutLine:' <errorlog><!![CDATA['; |
|
639 |
nextPutAll:exceptionInfo; |
|
640 |
nextPutLine:']]></errorlog>'. |
|
641 |
]. |
|
642 |
stream |
|
643 |
nextPutLine:' </result>'. |
|
644 |
||
645 |
stream nextPutLine:'</test>'. |
|
646 |
||
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
647 |
"Modified: / 06-06-2014 / 00:47:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
67 | 648 |
! ! |
649 |
||
650 |
!TestReportFormat::PythonUnittest class methodsFor:'accessing'! |
|
651 |
||
652 |
symbolicNames |
|
653 |
"Returns a collection of symbolic names for this format" |
|
654 |
||
655 |
^ #(python python-unittest) |
|
656 |
||
657 |
"Modified: / 04-08-2011 / 11:52:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
658 |
! ! |
|
659 |
||
660 |
!TestReportFormat::PythonUnittest class methodsFor:'documentation'! |
|
661 |
||
662 |
version_SVN |
|
191
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
663 |
^ '$Id$' |
67 | 664 |
! ! |
665 |
||
666 |
!TestReportFormat::PythonUnittest methodsFor:'writing'! |
|
667 |
||
668 |
writeFooter |
|
669 |
||
670 |
stream |
|
671 |
nextPutLine: '</unittest-results>' |
|
672 |
||
673 |
"Modified: / 03-08-2011 / 20:19:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
674 |
! |
|
675 |
||
676 |
writeHeader |
|
677 |
||
678 |
stream |
|
679 |
nextPutLine: '<?xml version="1.0"?>'; |
|
680 |
nextPutLine: '<unittest-results>'. |
|
681 |
||
682 |
"Modified: / 03-08-2011 / 20:19:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
683 |
! |
|
684 |
||
685 |
writeTestCase:testcase outcome:outcome time:time exception:exception stacktrace:stacktrace |
|
686 |
||
687 |
" |
|
688 |
Example: |
|
689 |
<test |
|
690 |
duration='0.0188629627228' |
|
691 |
status='error' |
|
692 |
fixture='bitten.tests.web_ui.SourceFileLinkFormatterTestCase' |
|
693 |
name='test_format_link_not_in_repos_with_line' |
|
694 |
file='/usr/src/trac-bitten-0.6b2.dfsg/bitten/tests/web_ui.py'> |
|
695 |
" |
|
696 |
||
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
697 |
| testClassName result | |
67 | 698 |
|
699 |
testClassName := testcase class printString. |
|
700 |
||
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
701 |
outcome result == TestResult statePass ifTrue:[ |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
702 |
result := #success. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
703 |
] ifFalse:[ |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
704 |
outcome result == TestResult stateFail ifTrue:[ |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
705 |
result := #failure. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
706 |
] ifFalse:[ |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
707 |
outcome result == TestResult stateError ifTrue:[ |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
708 |
result := #error. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
709 |
] ifFalse:[ |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
710 |
outcome result == TestResult stateSkip ifTrue:[ |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
711 |
result := #skip. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
712 |
] ifFalse:[ |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
713 |
self error: 'Invalid test result'. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
714 |
] |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
715 |
]. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
716 |
]. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
717 |
]. |
67 | 718 |
|
719 |
stream |
|
720 |
nextPutAll:'<test duration="'; nextPutAll:time; nextPutLine:'"'; |
|
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
721 |
tab; nextPutAll:'status="'; nextPutAll: result; nextPutLine:'"'; |
67 | 722 |
tab; nextPutAll:'ficture="'; nextPutAll: testClassName; nextPutLine:'"'; |
723 |
tab; nextPutAll:'name="'; nextPutAll: testcase selector; nextPutLine:'"'; |
|
724 |
"It seems that some tools requires the file attributes. So we supply one :-)" |
|
725 |
tab; nextPutAll:'file="'; nextPutAll: testClassName , '.st'; nextPutLine:'">'. |
|
726 |
||
727 |
outcome == #pass ifFalse:[ |
|
728 |
stream nextPutLine:'<traceback><!![CDATA['. |
|
729 |
stream nextPutAll: stacktrace ? 'No stacktrace available'. |
|
730 |
stream nextPutLine:']]></traceback>'. |
|
731 |
]. |
|
732 |
||
733 |
stream nextPutLine:'</test>'. |
|
734 |
||
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
735 |
"Modified: / 06-06-2014 / 00:50:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
67 | 736 |
! ! |
737 |
||
738 |
!TestReportFormat::TAP class methodsFor:'accessing'! |
|
739 |
||
740 |
symbolicNames |
|
741 |
"Returns a collection of symbolic names for this format" |
|
742 |
||
743 |
^ #(tap TAP) |
|
744 |
||
745 |
"Modified: / 04-08-2011 / 11:52:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
746 |
! ! |
|
747 |
||
748 |
!TestReportFormat::TAP class methodsFor:'documentation'! |
|
749 |
||
750 |
version_SVN |
|
191
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
751 |
^ '$Id$' |
67 | 752 |
! ! |
753 |
||
754 |
!TestReportFormat::TAP methodsFor:'accessing - defaults'! |
|
755 |
||
756 |
defaultFileSuffix |
|
757 |
"superclass HDReportFormat says that I am responsible to implement this method" |
|
758 |
||
759 |
^ 'tap' |
|
760 |
||
761 |
"Modified: / 04-08-2011 / 12:47:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
762 |
! ! |
|
763 |
||
764 |
!TestReportFormat::TAP methodsFor:'writing'! |
|
765 |
||
766 |
writeFooter |
|
767 |
||
768 |
"nothing to do" |
|
769 |
||
770 |
"Modified: / 03-08-2011 / 20:05:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
771 |
! |
|
772 |
||
773 |
writeHeader |
|
774 |
||
775 |
stream nextPutAll: '1..'; nextPutAll: report suite testCount printString; cr. |
|
776 |
index := 0 |
|
777 |
||
778 |
"Modified: / 04-08-2011 / 13:49:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
779 |
! |
|
780 |
||
781 |
writeTestCase:testcase outcome:outcome time:time exception:exception stacktrace:stacktrace |
|
782 |
||
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
783 |
| result testDescription statusString | |
67 | 784 |
|
785 |
index := index + 1. |
|
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
786 |
outcome result == TestResult statePass ifTrue:[ |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
787 |
result := #pass. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
788 |
] ifFalse:[ |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
789 |
outcome result == TestResult stateFail ifTrue:[ |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
790 |
result := #failure. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
791 |
] ifFalse:[ |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
792 |
outcome result == TestResult stateError ifTrue:[ |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
793 |
result := #error. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
794 |
] ifFalse:[ |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
795 |
outcome result == TestResult stateSkip ifTrue:[ |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
796 |
result := #skip. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
797 |
] ifFalse:[ |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
798 |
self error: 'Invalid test result'. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
799 |
] |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
800 |
]. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
801 |
]. |
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
802 |
]. |
67 | 803 |
|
804 |
testDescription := '%1-%2 (%3ms)' |
|
805 |
bindWith:testcase printString |
|
806 |
with:testcase selector |
|
807 |
with:time. |
|
808 |
||
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
809 |
statusString := (result == #pass) |
67 | 810 |
ifTrue:['ok'] |
811 |
ifFalse:['not ok']. |
|
812 |
||
813 |
stream nextPutLine:('%1 %2 - %3' |
|
814 |
bindWith:statusString |
|
815 |
with:index |
|
816 |
with:testDescription). |
|
817 |
||
235
3769ae14139a
When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
191
diff
changeset
|
818 |
"Modified: / 06-06-2014 / 00:46:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
67 | 819 |
! ! |
820 |
||
821 |
!TestReportFormat class methodsFor:'documentation'! |
|
822 |
||
823 |
version |
|
824 |
^ '$Header$' |
|
825 |
! |
|
826 |
||
827 |
version_CVS |
|
828 |
^ '$Header$' |
|
829 |
! |
|
830 |
||
296
4c26321be573
Test report: show also a bytecode for each method on the stack
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
248
diff
changeset
|
831 |
version_HG |
4c26321be573
Test report: show also a bytecode for each method on the stack
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
248
diff
changeset
|
832 |
|
4c26321be573
Test report: show also a bytecode for each method on the stack
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
248
diff
changeset
|
833 |
^ '$Changeset: <not expanded> $' |
4c26321be573
Test report: show also a bytecode for each method on the stack
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
248
diff
changeset
|
834 |
! |
4c26321be573
Test report: show also a bytecode for each method on the stack
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
248
diff
changeset
|
835 |
|
67 | 836 |
version_SVN |
191
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
837 |
^ '$Id$' |
67 | 838 |
! ! |
191
cc00c3e2019c
Fix for JUnit XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
104
diff
changeset
|
839 |