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