quickSelfTest/RunUnitTests.st
changeset 398 84b58f2602d9
parent 349 ed255c6cf368
child 399 98d1fb9a0b33
equal deleted inserted replaced
397:84e6ade7aad9 398:84b58f2602d9
   108     self logInfo:'generating report'.
   108     self logInfo:'generating report'.
   109     TestResultReporter
   109     TestResultReporter
   110 	report:result
   110 	report:result
   111 	format:#xml_jUnit
   111 	format:#xml_jUnit
   112 	as:'testresult.xml'.
   112 	as:'testresult.xml'.
       
   113 
       
   114     self logInfo:'summary:'.
       
   115     self logInfo:('%1 tests' bindWith:result runCount).
       
   116     self logInfo:('%1 passed' bindWith:result passedCount).
       
   117     self logInfo:('%1 failed' bindWith:result failureCount).
       
   118     self logInfo:('%1 errors' bindWith:result errorCount).
       
   119 !
       
   120 
       
   121 runWithCompiledUnitTestClasses:useCompiledUnitTestClasses
       
   122     |doRunSpecificUnitTests unitTestSuiteName excludedUnitTestClassNames corruptedUnitTestClassNames
       
   123      cmdArgs
       
   124      unitTestSuite
       
   125      eachClassName eachClass
       
   126      result index settingsFilePathName|
       
   127 
       
   128     doRunSpecificUnitTests := false.
       
   129     unitTestSuiteName := 'All Unit Tests'.
       
   130     excludedUnitTestClassNames := self excludedUnitTestClassNamesForAll.
       
   131     corruptedUnitTestClassNames := self corruptedUnitTestClassNames.
       
   132 
       
   133     cmdArgs := Smalltalk commandLineArguments.
       
   134     index := cmdArgs indexOf:'--settingsFile'.
       
   135     index > 0 ifTrue:[
       
   136         settingsFilePathName := cmdArgs at:index + 1.
       
   137         self logInfo:'load settings file: ', settingsFilePathName printString.
       
   138         settingsFilePathName asFilename fileIn.
       
   139         self logInfo:'ParserFlags makeCommand: ', ParserFlags makeCommand printString.
       
   140     ].
       
   141 
       
   142     (cmdArgs includes:'--runOnlyExpeccoUnitTests') ifTrue:[
       
   143         self logInfo:'configured to run expecco unit tests only'.
       
   144         doRunSpecificUnitTests := true.
       
   145         unitTestSuiteName := 'expecco Unit Tests'.
       
   146         excludedUnitTestClassNames := self excludedUnitTestClassNamesForExpecco.
       
   147     ].
       
   148 
       
   149     doRunSpecificUnitTests ifFalse:[
       
   150         self logInfo:'configured to run all available unit tests'.
       
   151     ].
       
   152 
       
   153     self logInfo:'collecting unit test classes to run'.
       
   154     unitTestSuite := TestSuite named:unitTestSuiteName.
       
   155 
       
   156 Transcript showCR:'1 ', (Smalltalk at: #'stx_goodies_regression') printString.
       
   157 Transcript showCR:'2 ', (Smalltalk at: #'stx_goodies_regression') classNamesAndAttributes printString.
       
   158 
       
   159     (Smalltalk at: #'stx_goodies_regression') classNamesAndAttributes do:[:eachClassNameAndAttributes |
       
   160         eachClassNameAndAttributes isSymbol ifTrue:[
       
   161             eachClassName := eachClassNameAndAttributes.
       
   162         ] ifFalse:[
       
   163             eachClassName := eachClassNameAndAttributes
       
   164                 firstIfEmpty:nil.
       
   165         ].
       
   166 
       
   167         (excludedUnitTestClassNames includes:eachClassName) ifFalse:[
       
   168             (corruptedUnitTestClassNames includes:eachClassName) ifTrue:[
       
   169                 self
       
   170                     logWarning:('corrupted unit test class detected, please fix #%1'
       
   171                         bindWith:eachClassName).
       
   172             ] ifFalse:[
       
   173                 eachClassName notNil ifTrue:[
       
   174                                 eachClass := Smalltalk
       
   175                                         fileInClass:eachClassName
       
   176                                         package:'stx:goodies/regression'.
       
   177 
       
   178                                 eachClass notNil ifTrue:[
       
   179                                 eachClass isTestCaseLike ifTrue:[
       
   180                                         unitTestSuite addTest:eachClass suite.
       
   181                                 ].
       
   182                     ].
       
   183                 ].
       
   184             ].
       
   185         ].
       
   186     ].
       
   187 
       
   188     self
       
   189         logInfo:('%1 unit test classes collected'
       
   190             bindWith:unitTestSuite tests size).
       
   191 
       
   192     self logInfo:'starting unit tests'.
       
   193     result := unitTestSuite
       
   194         run:TestResultStX new
       
   195         beforeEachDo:[:test | self logInfo:'performing unit test ', test printString]
       
   196         afterEachDo:[:test| ]
       
   197         debug:(cmdArgs includes:'--debug').
       
   198 
       
   199     self logInfo:'generating report'.
       
   200     TestResultReporter
       
   201         report:result
       
   202         format:#xml_jUnit
       
   203         as:'testresult.xml'.
   113 
   204 
   114     self logInfo:'summary:'.
   205     self logInfo:'summary:'.
   115     self logInfo:('%1 tests' bindWith:result runCount).
   206     self logInfo:('%1 tests' bindWith:result runCount).
   116     self logInfo:('%1 passed' bindWith:result passedCount).
   207     self logInfo:('%1 passed' bindWith:result passedCount).
   117     self logInfo:('%1 failed' bindWith:result failureCount).
   208     self logInfo:('%1 failed' bindWith:result failureCount).