45 arguments:cmdArgs |
45 arguments:cmdArgs |
46 debug:(cmdArgs includes:'--debug') |
46 debug:(cmdArgs includes:'--debug') |
47 ! |
47 ! |
48 |
48 |
49 runWithCompiledUnitTestClasses:useCompiledUnitTestClasses |
49 runWithCompiledUnitTestClasses:useCompiledUnitTestClasses |
50 arguments:arguments |
50 arguments:argumentsIn |
51 debug:debug |
51 debug:debug |
52 |
52 |
53 |doRunSpecificUnitTests unitTestSuiteName excludedUnitTestClassNames corruptedUnitTestClassNames |
53 |arguments |
|
54 doRunSpecificUnitTests unitTestSuiteName excludedUnitTestClassNames corruptedUnitTestClassNames |
54 unitTestSuite |
55 unitTestSuite |
55 eachClass |
56 eachClass |
56 result index |
57 result index |
57 settingsFilePathName resultFilePathName forceTestCase| |
58 settingsFilePathName resultFilePathName forceTestCase runTestCases| |
58 |
59 |
|
60 arguments := argumentsIn asOrderedCollection. |
|
61 |
|
62 runTestCases := OrderedCollection new. |
59 doRunSpecificUnitTests := false. |
63 doRunSpecificUnitTests := false. |
60 unitTestSuiteName := 'All Unit Tests'. |
64 unitTestSuiteName := 'All Unit Tests'. |
61 excludedUnitTestClassNames := self excludedUnitTestClassNamesForAll. |
65 excludedUnitTestClassNames := self excludedUnitTestClassNamesForAll. |
62 corruptedUnitTestClassNames := self corruptedUnitTestClassNames. |
66 corruptedUnitTestClassNames := self corruptedUnitTestClassNames. |
63 |
67 |
80 index > 0 ifTrue:[ |
84 index > 0 ifTrue:[ |
81 resultFilePathName := arguments at:index + 1. |
85 resultFilePathName := arguments at:index + 1. |
82 self logInfo:'set custom result file: ', resultFilePathName printString. |
86 self logInfo:'set custom result file: ', resultFilePathName printString. |
83 ]. |
87 ]. |
84 |
88 |
|
89 [ |
|
90 (index := arguments indexOf:'--run') > 0 |
|
91 ] whileTrue:[ |
|
92 runTestCases add:(arguments at:index + 1). |
|
93 self logInfo:'run test case: ', (arguments at:index + 1) printString. |
|
94 arguments removeIndex:index + 1. |
|
95 arguments removeIndex:index. |
|
96 ]. |
|
97 |
85 index := arguments indexOf:'--forceTestCase'. |
98 index := arguments indexOf:'--forceTestCase'. |
86 index > 0 ifTrue:[ |
99 index > 0 ifTrue:[ |
87 forceTestCase := arguments at:index + 1. |
100 forceTestCase := arguments at:index + 1. |
88 self logInfo:'set force test case: ', forceTestCase printString. |
101 self logInfo:'set force test case: ', forceTestCase printString. |
89 ]. |
102 ]. |
164 |
177 |
165 self |
178 self |
166 logInfo:('%1 unit test classes collected' |
179 logInfo:('%1 unit test classes collected' |
167 bindWith:unitTestSuite tests size). |
180 bindWith:unitTestSuite tests size). |
168 |
181 |
169 self logInfo:'starting unit tests'. |
182 self logInfo:'start tests...'. |
170 result := unitTestSuite |
183 result := unitTestSuite |
171 run:TestResultStX new |
184 run:TestResultStX new |
172 beforeEachDo:[:test | self logInfo:'performing unit test ', test printString] |
185 beforeEachDo:[:test | self logInfo:'performing unit test ', test printString] |
173 afterEachDo:[:test| ] |
186 afterEachDo:[:test| ] |
174 debug:debug. |
187 debug:debug. |
175 |
188 |
176 self logInfo:'generating report'. |
189 self logInfo:'tests finished.'. |
|
190 |
|
191 self logInfo:'generating xml report...'. |
177 TestResultReporter |
192 TestResultReporter |
178 report:result |
193 report:result |
179 format:#xml_jUnit |
194 format:#xml_jUnit |
180 as:resultFilePathName ? 'testresult.xml'. |
195 as:resultFilePathName ? 'testresult.xml'. |
181 |
196 |
182 self logInfo:'summary:'. |
197 self logInfo:('xml report in %1' bindWith:(resultFilePathName ? 'testresult.xml') asFilename pathName). |
183 self logInfo:('%1 tests' bindWith:result runCount). |
198 |
|
199 self logInfo:'Summary:'. |
|
200 self logInfo:('%1 tests' bindWith:result tests size). |
|
201 self logInfo:('%1 run' bindWith:result runCount). |
|
202 self logInfo:('%1 skipped' bindWith:result skippedCount). |
184 self logInfo:('%1 passed' bindWith:result passedCount). |
203 self logInfo:('%1 passed' bindWith:result passedCount). |
185 self logInfo:('%1 failed' bindWith:result failureCount). |
204 self logInfo:('%1 failed' bindWith:result failureCount). |
186 self logInfo:('%1 errors' bindWith:result errorCount). |
205 self logInfo:('%1 errors' bindWith:result errorCount). |
187 |
206 |
188 "Modified (format): / 16-05-2018 / 13:59:47 / sr" |
207 "Modified (format): / 16-05-2018 / 13:59:47 / sr" |
|
208 "Modified: / 26-03-2019 / 19:00:38 / Claus Gittinger" |
189 ! ! |
209 ! ! |
190 |
210 |
191 !RunUnitTests class methodsFor:'constants'! |
211 !RunUnitTests class methodsFor:'constants'! |
192 |
212 |
193 corruptedUnitTestClassNames |
213 corruptedUnitTestClassNames |
242 '--runOnlyExpeccoUnitTests' |
262 '--runOnlyExpeccoUnitTests' |
243 '--forceTestCase' |
263 '--forceTestCase' |
244 'ExternalStreamTest' |
264 'ExternalStreamTest' |
245 ) |
265 ) |
246 debug:true |
266 debug:true |
|
267 ! |
|
268 |
|
269 example2 |
|
270 Processor activeProcess exceptionHandlerSet |
|
271 on:Class updateChangeFileQuerySignal |
|
272 do:[:ex | ex proceedWith:false]. |
|
273 |
|
274 self |
|
275 runWithCompiledUnitTestClasses:true |
|
276 arguments:#( |
|
277 '--forceTestCase' |
|
278 'RegressionTests::ExternalStreamTest' |
|
279 ) |
|
280 debug:true |
|
281 |
|
282 "Created: / 26-03-2019 / 18:46:46 / Claus Gittinger" |
|
283 ! |
|
284 |
|
285 example2b |
|
286 Processor activeProcess exceptionHandlerSet |
|
287 on:Class updateChangeFileQuerySignal |
|
288 do:[:ex | ex proceedWith:false]. |
|
289 |
|
290 self |
|
291 runWithCompiledUnitTestClasses:true |
|
292 arguments:#( |
|
293 '--forceTestCase' |
|
294 'ExternalStreamTest' |
|
295 ) |
|
296 debug:true |
|
297 |
|
298 "Created: / 26-03-2019 / 18:55:46 / Claus Gittinger" |
|
299 ! |
|
300 |
|
301 example2c |
|
302 Processor activeProcess exceptionHandlerSet |
|
303 on:Class updateChangeFileQuerySignal |
|
304 do:[:ex | ex proceedWith:false]. |
|
305 |
|
306 self |
|
307 runWithCompiledUnitTestClasses:true |
|
308 arguments:#( |
|
309 '--forceTestCase' |
|
310 'CRCTests' |
|
311 ) |
|
312 debug:true |
|
313 |
|
314 "Created: / 26-03-2019 / 18:58:36 / Claus Gittinger" |
|
315 ! |
|
316 |
|
317 example3 |
|
318 Processor activeProcess exceptionHandlerSet |
|
319 on:Class updateChangeFileQuerySignal |
|
320 do:[:ex | ex proceedWith:false]. |
|
321 |
|
322 self |
|
323 runWithCompiledUnitTestClasses:true |
|
324 arguments:#( |
|
325 '--run' |
|
326 'ExternalStreamTest' |
|
327 ) |
|
328 debug:true |
|
329 |
|
330 "Created: / 26-03-2019 / 18:51:42 / Claus Gittinger" |
247 ! ! |
331 ! ! |
248 |
332 |
249 !RunUnitTests class methodsFor:'logging'! |
333 !RunUnitTests class methodsFor:'logging'! |
250 |
334 |
251 log:aString |
335 log:aString type:aType |
252 type:aType |
336 Transcript notNil ifTrue:[ |
253 |
337 Transcript showCR:'%1 [%2] : %3' |
254 Stdout |
338 with:Timestamp now printString |
255 showCR:('%1 [%2] : %3' |
339 with:(aType printString asLowercase paddedTo:'warning' size) |
256 bindWith:Timestamp now printString |
340 with:aString. |
257 with:(aType printString asLowercase paddedTo:'warning' size) |
341 ^ self |
258 with:aString). |
342 ]. |
|
343 Stderr showCR:'%1 [%2] : %3' |
|
344 with:Timestamp now printString |
|
345 with:(aType printString asLowercase paddedTo:'warning' size) |
|
346 with:aString. |
|
347 |
|
348 "Modified: / 26-03-2019 / 18:53:48 / Claus Gittinger" |
259 ! |
349 ! |
260 |
350 |
261 logInfo:aString |
351 logInfo:aString |
262 self |
352 self |
263 log:aString |
353 log:aString |