#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Tue, 26 Mar 2019 19:01:31 +0100
changeset 539532fab2fb2a5
parent 538 3dc87166e57d
child 540 743b92de4b9b
#FEATURE by cg
class: RunUnitTests
class definition

class: RunUnitTests class
added:17 methods
quickSelfTest/RunUnitTests.st
     1.1 --- a/quickSelfTest/RunUnitTests.st	Tue Mar 26 18:47:59 2019 +0100
     1.2 +++ b/quickSelfTest/RunUnitTests.st	Tue Mar 26 19:01:31 2019 +0100
     1.3 @@ -15,10 +15,10 @@
     1.4  
     1.5  documentation
     1.6  "
     1.7 -    documentation to be added.
     1.8 +    typically invoked by RunUnitTestsStart
     1.9  
    1.10      [author:]
    1.11 -	sr
    1.12 +        sr
    1.13  
    1.14      [instance variables:]
    1.15  
    1.16 @@ -47,15 +47,19 @@
    1.17  !
    1.18  
    1.19  runWithCompiledUnitTestClasses:useCompiledUnitTestClasses
    1.20 -    arguments:arguments
    1.21 +    arguments:argumentsIn
    1.22      debug:debug
    1.23  
    1.24 -    |doRunSpecificUnitTests unitTestSuiteName excludedUnitTestClassNames corruptedUnitTestClassNames
    1.25 +    |arguments
    1.26 +     doRunSpecificUnitTests unitTestSuiteName excludedUnitTestClassNames corruptedUnitTestClassNames
    1.27       unitTestSuite
    1.28       eachClass
    1.29       result index
    1.30 -     settingsFilePathName resultFilePathName forceTestCase|
    1.31 +     settingsFilePathName resultFilePathName forceTestCase runTestCases|
    1.32  
    1.33 +    arguments := argumentsIn asOrderedCollection.
    1.34 +
    1.35 +    runTestCases := OrderedCollection new.
    1.36      doRunSpecificUnitTests := false.
    1.37      unitTestSuiteName := 'All Unit Tests'.
    1.38      excludedUnitTestClassNames := self excludedUnitTestClassNamesForAll.
    1.39 @@ -82,6 +86,15 @@
    1.40          self logInfo:'set custom result file: ', resultFilePathName printString.
    1.41      ].
    1.42  
    1.43 +    [   
    1.44 +        (index := arguments indexOf:'--run') > 0 
    1.45 +    ] whileTrue:[
    1.46 +        runTestCases add:(arguments at:index + 1).
    1.47 +        self logInfo:'run test case: ', (arguments at:index + 1) printString.
    1.48 +        arguments removeIndex:index + 1.
    1.49 +        arguments removeIndex:index.
    1.50 +    ].
    1.51 +    
    1.52      index := arguments indexOf:'--forceTestCase'.
    1.53      index > 0 ifTrue:[
    1.54          forceTestCase := arguments at:index + 1.
    1.55 @@ -166,26 +179,33 @@
    1.56          logInfo:('%1 unit test classes collected'
    1.57              bindWith:unitTestSuite tests size).
    1.58  
    1.59 -    self logInfo:'starting unit tests'.
    1.60 +    self logInfo:'start tests...'.
    1.61      result := unitTestSuite
    1.62          run:TestResultStX new
    1.63          beforeEachDo:[:test | self logInfo:'performing unit test ', test printString]
    1.64          afterEachDo:[:test| ]
    1.65          debug:debug.
    1.66  
    1.67 -    self logInfo:'generating report'.
    1.68 +    self logInfo:'tests finished.'.
    1.69 +    
    1.70 +    self logInfo:'generating xml report...'.
    1.71      TestResultReporter
    1.72          report:result
    1.73          format:#xml_jUnit
    1.74          as:resultFilePathName ? 'testresult.xml'.
    1.75  
    1.76 -    self logInfo:'summary:'.
    1.77 -    self logInfo:('%1 tests' bindWith:result runCount).
    1.78 +    self logInfo:('xml report in %1' bindWith:(resultFilePathName ? 'testresult.xml') asFilename pathName).
    1.79 +
    1.80 +    self logInfo:'Summary:'.
    1.81 +    self logInfo:('%1 tests' bindWith:result tests size).
    1.82 +    self logInfo:('%1 run' bindWith:result runCount).
    1.83 +    self logInfo:('%1 skipped' bindWith:result skippedCount).
    1.84      self logInfo:('%1 passed' bindWith:result passedCount).
    1.85      self logInfo:('%1 failed' bindWith:result failureCount).
    1.86      self logInfo:('%1 errors' bindWith:result errorCount).
    1.87  
    1.88      "Modified (format): / 16-05-2018 / 13:59:47 / sr"
    1.89 +    "Modified: / 26-03-2019 / 19:00:38 / Claus Gittinger"
    1.90  ! !
    1.91  
    1.92  !RunUnitTests class methodsFor:'constants'!
    1.93 @@ -244,18 +264,88 @@
    1.94  	    'ExternalStreamTest'
    1.95  	)
    1.96  	debug:true
    1.97 +!
    1.98 +
    1.99 +example2
   1.100 +    Processor activeProcess exceptionHandlerSet
   1.101 +        on:Class updateChangeFileQuerySignal
   1.102 +        do:[:ex | ex proceedWith:false].
   1.103 +
   1.104 +    self
   1.105 +        runWithCompiledUnitTestClasses:true
   1.106 +        arguments:#(
   1.107 +            '--forceTestCase'
   1.108 +            'RegressionTests::ExternalStreamTest'
   1.109 +        )
   1.110 +        debug:true
   1.111 +
   1.112 +    "Created: / 26-03-2019 / 18:46:46 / Claus Gittinger"
   1.113 +!
   1.114 +
   1.115 +example2b
   1.116 +    Processor activeProcess exceptionHandlerSet
   1.117 +        on:Class updateChangeFileQuerySignal
   1.118 +        do:[:ex | ex proceedWith:false].
   1.119 +
   1.120 +    self
   1.121 +        runWithCompiledUnitTestClasses:true
   1.122 +        arguments:#(
   1.123 +            '--forceTestCase'
   1.124 +            'ExternalStreamTest'
   1.125 +        )
   1.126 +        debug:true
   1.127 +
   1.128 +    "Created: / 26-03-2019 / 18:55:46 / Claus Gittinger"
   1.129 +!
   1.130 +
   1.131 +example2c
   1.132 +    Processor activeProcess exceptionHandlerSet
   1.133 +        on:Class updateChangeFileQuerySignal
   1.134 +        do:[:ex | ex proceedWith:false].
   1.135 +
   1.136 +    self
   1.137 +        runWithCompiledUnitTestClasses:true
   1.138 +        arguments:#(
   1.139 +            '--forceTestCase'
   1.140 +            'CRCTests'
   1.141 +        )
   1.142 +        debug:true
   1.143 +
   1.144 +    "Created: / 26-03-2019 / 18:58:36 / Claus Gittinger"
   1.145 +!
   1.146 +
   1.147 +example3
   1.148 +    Processor activeProcess exceptionHandlerSet
   1.149 +        on:Class updateChangeFileQuerySignal
   1.150 +        do:[:ex | ex proceedWith:false].
   1.151 +
   1.152 +    self
   1.153 +        runWithCompiledUnitTestClasses:true
   1.154 +        arguments:#(
   1.155 +            '--run'
   1.156 +            'ExternalStreamTest'
   1.157 +        )
   1.158 +        debug:true
   1.159 +
   1.160 +    "Created: / 26-03-2019 / 18:51:42 / Claus Gittinger"
   1.161  ! !
   1.162  
   1.163  !RunUnitTests class methodsFor:'logging'!
   1.164  
   1.165 -log:aString
   1.166 -    type:aType
   1.167 +log:aString type:aType
   1.168 +    Transcript notNil ifTrue:[
   1.169 +        Transcript showCR:'%1 [%2] : %3'
   1.170 +                with:Timestamp now printString
   1.171 +                with:(aType printString asLowercase paddedTo:'warning' size)
   1.172 +                with:aString.
   1.173 +        ^ self       
   1.174 +    ].    
   1.175 +    Stderr showCR:'%1 [%2] : %3'
   1.176 +            with:Timestamp now printString
   1.177 +            with:(aType printString asLowercase paddedTo:'warning' size)
   1.178 +            with:aString.
   1.179  
   1.180 -    Stdout
   1.181 -	showCR:('%1 [%2] : %3'
   1.182 -	    bindWith:Timestamp now printString
   1.183 -	    with:(aType printString asLowercase paddedTo:'warning' size)
   1.184 -	    with:aString).
   1.185 +    "Modified: / 26-03-2019 / 18:53:48 / Claus Gittinger"
   1.186  !
   1.187  
   1.188  logInfo:aString