# HG changeset patch # User Claus Gittinger # Date 1553623291 -3600 # Node ID 532fab2fb2a5edbaf07478858a40fd94a45f3f6e # Parent 3dc87166e57dc2065324de1c115bb392d916057f #FEATURE by cg class: RunUnitTests class definition class: RunUnitTests class added:17 methods diff -r 3dc87166e57d -r 532fab2fb2a5 quickSelfTest/RunUnitTests.st --- a/quickSelfTest/RunUnitTests.st Tue Mar 26 18:47:59 2019 +0100 +++ b/quickSelfTest/RunUnitTests.st Tue Mar 26 19:01:31 2019 +0100 @@ -15,10 +15,10 @@ documentation " - documentation to be added. + typically invoked by RunUnitTestsStart [author:] - sr + sr [instance variables:] @@ -47,15 +47,19 @@ ! runWithCompiledUnitTestClasses:useCompiledUnitTestClasses - arguments:arguments + arguments:argumentsIn debug:debug - |doRunSpecificUnitTests unitTestSuiteName excludedUnitTestClassNames corruptedUnitTestClassNames + |arguments + doRunSpecificUnitTests unitTestSuiteName excludedUnitTestClassNames corruptedUnitTestClassNames unitTestSuite eachClass result index - settingsFilePathName resultFilePathName forceTestCase| + settingsFilePathName resultFilePathName forceTestCase runTestCases| + arguments := argumentsIn asOrderedCollection. + + runTestCases := OrderedCollection new. doRunSpecificUnitTests := false. unitTestSuiteName := 'All Unit Tests'. excludedUnitTestClassNames := self excludedUnitTestClassNamesForAll. @@ -82,6 +86,15 @@ self logInfo:'set custom result file: ', resultFilePathName printString. ]. + [ + (index := arguments indexOf:'--run') > 0 + ] whileTrue:[ + runTestCases add:(arguments at:index + 1). + self logInfo:'run test case: ', (arguments at:index + 1) printString. + arguments removeIndex:index + 1. + arguments removeIndex:index. + ]. + index := arguments indexOf:'--forceTestCase'. index > 0 ifTrue:[ forceTestCase := arguments at:index + 1. @@ -166,26 +179,33 @@ logInfo:('%1 unit test classes collected' bindWith:unitTestSuite tests size). - self logInfo:'starting unit tests'. + self logInfo:'start tests...'. result := unitTestSuite run:TestResultStX new beforeEachDo:[:test | self logInfo:'performing unit test ', test printString] afterEachDo:[:test| ] debug:debug. - self logInfo:'generating report'. + self logInfo:'tests finished.'. + + self logInfo:'generating xml report...'. TestResultReporter report:result format:#xml_jUnit as:resultFilePathName ? 'testresult.xml'. - self logInfo:'summary:'. - self logInfo:('%1 tests' bindWith:result runCount). + self logInfo:('xml report in %1' bindWith:(resultFilePathName ? 'testresult.xml') asFilename pathName). + + self logInfo:'Summary:'. + self logInfo:('%1 tests' bindWith:result tests size). + self logInfo:('%1 run' bindWith:result runCount). + self logInfo:('%1 skipped' bindWith:result skippedCount). self logInfo:('%1 passed' bindWith:result passedCount). self logInfo:('%1 failed' bindWith:result failureCount). self logInfo:('%1 errors' bindWith:result errorCount). "Modified (format): / 16-05-2018 / 13:59:47 / sr" + "Modified: / 26-03-2019 / 19:00:38 / Claus Gittinger" ! ! !RunUnitTests class methodsFor:'constants'! @@ -244,18 +264,88 @@ 'ExternalStreamTest' ) debug:true +! + +example2 + Processor activeProcess exceptionHandlerSet + on:Class updateChangeFileQuerySignal + do:[:ex | ex proceedWith:false]. + + self + runWithCompiledUnitTestClasses:true + arguments:#( + '--forceTestCase' + 'RegressionTests::ExternalStreamTest' + ) + debug:true + + "Created: / 26-03-2019 / 18:46:46 / Claus Gittinger" +! + +example2b + Processor activeProcess exceptionHandlerSet + on:Class updateChangeFileQuerySignal + do:[:ex | ex proceedWith:false]. + + self + runWithCompiledUnitTestClasses:true + arguments:#( + '--forceTestCase' + 'ExternalStreamTest' + ) + debug:true + + "Created: / 26-03-2019 / 18:55:46 / Claus Gittinger" +! + +example2c + Processor activeProcess exceptionHandlerSet + on:Class updateChangeFileQuerySignal + do:[:ex | ex proceedWith:false]. + + self + runWithCompiledUnitTestClasses:true + arguments:#( + '--forceTestCase' + 'CRCTests' + ) + debug:true + + "Created: / 26-03-2019 / 18:58:36 / Claus Gittinger" +! + +example3 + Processor activeProcess exceptionHandlerSet + on:Class updateChangeFileQuerySignal + do:[:ex | ex proceedWith:false]. + + self + runWithCompiledUnitTestClasses:true + arguments:#( + '--run' + 'ExternalStreamTest' + ) + debug:true + + "Created: / 26-03-2019 / 18:51:42 / Claus Gittinger" ! ! !RunUnitTests class methodsFor:'logging'! -log:aString - type:aType +log:aString type:aType + Transcript notNil ifTrue:[ + Transcript showCR:'%1 [%2] : %3' + with:Timestamp now printString + with:(aType printString asLowercase paddedTo:'warning' size) + with:aString. + ^ self + ]. + Stderr showCR:'%1 [%2] : %3' + with:Timestamp now printString + with:(aType printString asLowercase paddedTo:'warning' size) + with:aString. - Stdout - showCR:('%1 [%2] : %3' - bindWith:Timestamp now printString - with:(aType printString asLowercase paddedTo:'warning' size) - with:aString). + "Modified: / 26-03-2019 / 18:53:48 / Claus Gittinger" ! logInfo:aString