Tools__TestRunner2.st
branchjv
changeset 19612 9f2e3136aa4d
parent 17137 2c2f7c9fc909
child 19638 f0275261f2ca
equal deleted inserted replaced
19611:a4b9d283ca40 19612:9f2e3136aa4d
     1 "
     1 "
     2  Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague
     2  Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague
     3  Copyright (c) 2009-2010 eXept Software AG
     3  Copyright (c) 2009-2010 eXept Software AG
       
     4  Copyright (c) 2021 LabWare
     4 
     5 
     5  Permission is hereby granted, free of charge, to any person
     6  Permission is hereby granted, free of charge, to any person
     6  obtaining a copy of this software and associated documentation
     7  obtaining a copy of this software and associated documentation
     7  files (the 'Software'), to deal in the Software without
     8  files (the 'Software'), to deal in the Software without
     8  restriction, including without limitation the rights to use,
     9  restriction, including without limitation the rights to use,
    44 	classVariableNames:''
    45 	classVariableNames:''
    45 	poolDictionaries:''
    46 	poolDictionaries:''
    46 	privateIn:TestRunner2
    47 	privateIn:TestRunner2
    47 !
    48 !
    48 
    49 
    49 ApplicationModel subclass:#ResultList
    50 AbstractTestRunner subclass:#ResultList
    50 	instanceVariableNames:'results resultsHolder selectiomHolder listHolder timestampFormat
    51 	instanceVariableNames:'results resultsHolder selectiomHolder listHolder timestampFormat
    51 		selectionHolder'
    52 		selectionHolder passedText failedText errorText'
    52 	classVariableNames:''
    53 	classVariableNames:''
    53 	poolDictionaries:''
    54 	poolDictionaries:''
    54 	privateIn:TestRunner2
    55 	privateIn:TestRunner2
    55 !
    56 !
    56 
    57 
    57 HierarchicalItem subclass:#ListEntry
    58 HierarchicalItem subclass:#ListEntry
    58 	instanceVariableNames:'label realLabel test result'
    59 	instanceVariableNames:'label realLabel test result'
    59 	classVariableNames:'PassedText FailedText ErrorText'
    60 	classVariableNames:''
    60 	poolDictionaries:''
    61 	poolDictionaries:''
    61 	privateIn:TestRunner2::ResultList
    62 	privateIn:TestRunner2::ResultList
    62 !
    63 !
    63 
    64 
    64 !TestRunner2 class methodsFor:'documentation'!
    65 !TestRunner2 class methodsFor:'documentation'!
    65 
    66 
    66 copyright
    67 copyright
    67 "
    68 "
    68  Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague
    69  Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague
    69  Copyright (c) 2009-2010 eXept Software AG
    70  Copyright (c) 2009-2010 eXept Software AG
       
    71  Copyright (c) 2021 LabWare
    70 
    72 
    71  Permission is hereby granted, free of charge, to any person
    73  Permission is hereby granted, free of charge, to any person
    72  obtaining a copy of this software and associated documentation
    74  obtaining a copy of this software and associated documentation
    73  files (the 'Software'), to deal in the Software without
    75  files (the 'Software'), to deal in the Software without
    74  restriction, including without limitation the rights to use,
    76  restriction, including without limitation the rights to use,
  1050     "Created: / 06-07-2011 / 14:10:00 / cg"
  1052     "Created: / 06-07-2011 / 14:10:00 / cg"
  1051 ! !
  1053 ! !
  1052 
  1054 
  1053 !TestRunner2 methodsFor:'accessing'!
  1055 !TestRunner2 methodsFor:'accessing'!
  1054 
  1056 
  1055 errorColor
       
  1056     ^ self class 
       
  1057         errorColor
       
  1058 
       
  1059     "Modified: / 08-02-2010 / 13:57:26 / Jan Vrany <jan,vrany@fit.cvut.cz>"
       
  1060 !
       
  1061 
       
  1062 errorTestSuite
  1057 errorTestSuite
  1063 
  1058 
  1064     | testSuite |
  1059     | testSuite |
  1065     testSuite := TestSuite new.
  1060     testSuite := TestSuite new.
  1066     errorListHolder value do:
  1061     errorListHolder value do:
  1069     ^testSuite
  1064     ^testSuite
  1070 
  1065 
  1071     "Created: / 06-06-2008 / 09:08:40 / Jan Vrany <vranyj1@fel.cvut.cz>"
  1066     "Created: / 06-06-2008 / 09:08:40 / Jan Vrany <vranyj1@fel.cvut.cz>"
  1072 !
  1067 !
  1073 
  1068 
  1074 failedColor
       
  1075     ^ self class failedColor
       
  1076 !
       
  1077 
       
  1078 failureTestSuite
  1069 failureTestSuite
  1079     | testSuite |
  1070     | testSuite |
  1080 
  1071 
  1081     testSuite := TestSuite new.
  1072     testSuite := TestSuite new.
  1082     failureListHolder value do:[:test|
  1073     failureListHolder value do:[:test|
  1084     ].
  1075     ].
  1085     ^testSuite
  1076     ^testSuite
  1086 
  1077 
  1087     "Created: / 06-06-2008 / 09:03:55 / Jan Vrany <vranyj1@fel.cvut.cz>"
  1078     "Created: / 06-06-2008 / 09:03:55 / Jan Vrany <vranyj1@fel.cvut.cz>"
  1088     "Modified (format): / 23-09-2011 / 18:56:52 / cg"
  1079     "Modified (format): / 23-09-2011 / 18:56:52 / cg"
  1089 !
       
  1090 
       
  1091 passedColor
       
  1092     ^ self class passedColor
       
  1093 !
  1080 !
  1094 
  1081 
  1095 selectedPackages: packages
  1082 selectedPackages: packages
  1096 
  1083 
  1097     self packageList selectedProjects value: packages.
  1084     self packageList selectedProjects value: packages.
  1800     "Modified: / 02-04-2000 / 14:21:42 / Sames"
  1787     "Modified: / 02-04-2000 / 14:21:42 / Sames"
  1801     "Created: / 18-01-2008 / 20:33:51 / janfrog"
  1788     "Created: / 18-01-2008 / 20:33:51 / janfrog"
  1802 !
  1789 !
  1803 
  1790 
  1804 displayFail:result 
  1791 displayFail:result 
  1805     self displayColor:self errorColor.
  1792     self displayColor:self errorBackgroundColor.
  1806     self displayMode:'Fail'.
  1793     self displayMode:'Fail'.
  1807     self displayDetails:result printString.
  1794     self displayDetails:result printString.
  1808 
  1795 
  1809     "Created: / 06-06-2008 / 08:49:25 / Jan Vrany <vranyj1@fel.cvut.cz>"
  1796     "Created: / 06-06-2008 / 08:49:25 / Jan Vrany <vranyj1@fel.cvut.cz>"
  1810     "Modified: / 07-02-2010 / 14:43:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1797     "Modified: / 07-02-2010 / 14:43:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
  1798     "Modified: / 17-09-2021 / 22:23:42 / Jan Vrany <jan.vrany@labware.com>"
  1811 !
  1799 !
  1812 
  1800 
  1813 displayMode: mode
  1801 displayMode: mode
  1814 
  1802 
  1815         self modeHolder value: mode
  1803         self modeHolder value: mode
  1817     "Modified: / 02-04-2000 / 14:21:42 / Sames"
  1805     "Modified: / 02-04-2000 / 14:21:42 / Sames"
  1818     "Created: / 18-01-2008 / 20:33:35 / janfrog"
  1806     "Created: / 18-01-2008 / 20:33:35 / janfrog"
  1819 !
  1807 !
  1820 
  1808 
  1821 displayPass:result 
  1809 displayPass:result 
  1822     self displayColor:self passedColor.
  1810     self displayColor:self passedBackgroundColor.
  1823     self displayMode:'Pass '.
  1811     self displayMode:'Pass '.
  1824     self 
  1812     self 
  1825         displayDetails:result printString , ' ' , (self timeSinceLastPassAsString)
  1813         displayDetails:result printString , ' ' , (self timeSinceLastPassAsString)
       
  1814 
       
  1815     "Modified: / 17-09-2021 / 22:23:51 / Jan Vrany <jan.vrany@labware.com>"
  1826 !
  1816 !
  1827 
  1817 
  1828 displayResult: aTestResult
  1818 displayResult: aTestResult
  1829 
  1819 
  1830     self displayResult: aTestResult keepFailures: false keepErrors: false.
  1820     self displayResult: aTestResult keepFailures: false keepErrors: false.
  1859     "Modified: / 19-03-2010 / 08:33:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1849     "Modified: / 19-03-2010 / 08:33:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1860 !
  1850 !
  1861 
  1851 
  1862 displayRunning: result test: test total: total
  1852 displayRunning: result test: test total: total
  1863 
  1853 
  1864     self displayColor: (result hasPassed ifTrue:[self class currentlyRunningColor] ifFalse:[Color orange]).
  1854     self displayColor: self runningBackgroundColor.
  1865     self displayMode: 'Running ' , test printString.
  1855     self displayMode: 'Running ' , test printString.
  1866     self displayDetails: total printString , ' total, ' , result printString
  1856     self displayDetails: total printString , ' total, ' , result printString
  1867 
  1857 
  1868     "Modified: / 21-06-2000 / 12:14:52 / Sames"
  1858     "Modified: / 21-06-2000 / 12:14:52 / Sames"
  1869     "Created: / 06-06-2008 / 19:38:48 / Jan Vrany <vranyj1@fel.cvut.cz>"
  1859     "Created: / 06-06-2008 / 19:38:48 / Jan Vrany <vranyj1@fel.cvut.cz>"
  1870     "Modified: / 05-07-2011 / 14:14:42 / cg"
  1860     "Modified: / 05-07-2011 / 14:14:42 / cg"
       
  1861     "Modified: / 17-09-2021 / 22:24:33 / Jan Vrany <jan.vrany@labware.com>"
  1871 ! !
  1862 ! !
  1872 
  1863 
  1873 !TestRunner2 methodsFor:'hooks'!
  1864 !TestRunner2 methodsFor:'hooks'!
  1874 
  1865 
  1875 commonPostOpen
  1866 commonPostOpen
  2022         #selectionHolder
  2013         #selectionHolder
  2023       ).
  2014       ).
  2024 
  2015 
  2025 ! !
  2016 ! !
  2026 
  2017 
       
  2018 !TestRunner2::ResultList methodsFor:'accessing'!
       
  2019 
       
  2020 errorText
       
  2021     ^ errorText
       
  2022 !
       
  2023 
       
  2024 failedText
       
  2025     ^ failedText
       
  2026 !
       
  2027 
       
  2028 passedText
       
  2029     ^ passedText
       
  2030 ! !
       
  2031 
  2027 !TestRunner2::ResultList methodsFor:'actions'!
  2032 !TestRunner2::ResultList methodsFor:'actions'!
  2028 
  2033 
  2029 debugTest:entryIndex 
  2034 debugTest:entryIndex 
  2030     |entry test caughtEx|
  2035     |entry test caughtEx|
  2031 
  2036 
  2127 
  2132 
  2128 updateList
  2133 updateList
  2129 
  2134 
  2130     | list |
  2135     | list |
  2131     list := HierarchicalList new.
  2136     list := HierarchicalList new.
       
  2137     list application: self.
  2132     list root: self makeRootEntry.            
  2138     list root: self makeRootEntry.            
  2133     list showRoot: false.    
  2139     list showRoot: false.    
  2134     self listHolder value: list.
  2140     self listHolder value: list.
  2135 
  2141 
  2136     "Created: / 07-02-2010 / 11:03:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2142     "Created: / 07-02-2010 / 11:03:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2137     "Modified: / 07-02-2010 / 13:41:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2143     "Modified: / 07-02-2010 / 13:41:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
  2144     "Modified: / 17-09-2021 / 22:50:17 / Jan Vrany <jan.vrany@labware.com>"
  2138 !
  2145 !
  2139 
  2146 
  2140 updateTimestampFormat
  2147 updateTimestampFormat
  2141 
  2148 
  2142     (results isEmptyOrNil or:[results size = 1])
  2149     (results isEmptyOrNil or:[results size = 1])
  2147         ifFalse:[timestampFormat := ' (%(month)-%(day) %h:%m)']
  2154         ifFalse:[timestampFormat := ' (%(month)-%(day) %h:%m)']
  2148 
  2155 
  2149     "Created: / 19-03-2010 / 08:50:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2156     "Created: / 19-03-2010 / 08:50:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2150     "Modified: / 12-09-2010 / 09:50:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2157     "Modified: / 12-09-2010 / 09:50:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2151     "Modified: / 04-08-2011 / 19:05:57 / cg"
  2158     "Modified: / 04-08-2011 / 19:05:57 / cg"
       
  2159 ! !
       
  2160 
       
  2161 !TestRunner2::ResultList methodsFor:'initialization'!
       
  2162 
       
  2163 initialize
       
  2164     "Invoked when a new instance is created."
       
  2165 
       
  2166     super initialize.
       
  2167 
       
  2168     passedText := (' [', (self resources string:'passed') , ']') withColor: self passedBackgroundColor. 
       
  2169     failedText := (' [', (self resources string:'failed') allBold , ']') withColor: self failedBackgroundColor. 
       
  2170     errorText :=  (' [', (self resources string:'error') allBold , ']') withColor: self errorBackgroundColor. 
       
  2171 
       
  2172     "/ super initialize.   -- commented since inherited method does nothing
  2152 ! !
  2173 ! !
  2153 
  2174 
  2154 !TestRunner2::ResultList methodsFor:'private'!
  2175 !TestRunner2::ResultList methodsFor:'private'!
  2155 
  2176 
  2156 invalidate
  2177 invalidate
  2243     ^entry
  2264     ^entry
  2244 
  2265 
  2245     "Created: / 19-03-2010 / 08:41:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2266     "Created: / 19-03-2010 / 08:41:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2246 ! !
  2267 ! !
  2247 
  2268 
  2248 !TestRunner2::ResultList::ListEntry class methodsFor:'initialization'!
       
  2249 
       
  2250 errorText
       
  2251     ErrorText isNil ifTrue:[
       
  2252         ErrorText := ' [','error' allBold,']' withColor: Tools::TestRunner2 errorColor "darker".    
       
  2253     ].
       
  2254     ^ ErrorText
       
  2255 
       
  2256     "Created: / 06-06-2016 / 14:41:59 / cg"
       
  2257 !
       
  2258 
       
  2259 failedText
       
  2260     FailedText isNil ifTrue:[
       
  2261         FailedText := ' [','failed' allBold,']' withColor: Tools::TestRunner2 failedColor "darker".
       
  2262     ].
       
  2263     ^ FailedText
       
  2264 
       
  2265     "Created: / 06-06-2016 / 14:41:40 / cg"
       
  2266 !
       
  2267 
       
  2268 passedText
       
  2269     PassedText isNil ifTrue:[
       
  2270         PassedText := ' [passed]' withColor: Tools::TestRunner2 passedColor darker.
       
  2271     ].
       
  2272     ^ PassedText
       
  2273 
       
  2274     "Created: / 06-06-2016 / 14:41:16 / cg"
       
  2275 ! !
       
  2276 
       
  2277 !TestRunner2::ResultList::ListEntry class methodsFor:'instance creation'!
  2269 !TestRunner2::ResultList::ListEntry class methodsFor:'instance creation'!
  2278 
  2270 
  2279 labeled: aStringOrText
  2271 labeled: aStringOrText
  2280 
  2272 
  2281     ^self new label: aStringOrText
  2273     ^self new label: aStringOrText
  2293 
  2285 
  2294     "Created: / 07-02-2010 / 18:34:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2286     "Created: / 07-02-2010 / 18:34:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2295 !
  2287 !
  2296 
  2288 
  2297 label
  2289 label
  2298     | result |
  2290 
  2299 
  2291     self result. "/ to ensure result is computed
  2300     result := self result.
       
  2301     realLabel ifNil:[
  2292     realLabel ifNil:[
  2302         realLabel := label.
  2293         realLabel := label.
  2303         test ifNotNil:[
  2294         test ifNotNil:[
  2304             result == #passed ifTrue:[realLabel := realLabel , self class passedText].
  2295             result == #passed ifTrue:[realLabel := realLabel , self application passedText].
  2305             result == #error ifTrue:[realLabel := realLabel , self class errorText].
  2296             result == #error ifTrue:[realLabel := realLabel , self application errorText].
  2306             result == #failed ifTrue:[realLabel := realLabel , self class failedText].
  2297             result == #failed ifTrue:[realLabel := realLabel , self application failedText].
  2307         ] ifNil: [
  2298         ] ifNil: [
  2308             realLabel := realLabel , self summary.
  2299             realLabel := realLabel , self summary.
  2309         ]        
  2300         ]        
  2310     ].
  2301     ].
  2311 
  2302 
  2312     ^ realLabel
  2303     ^ realLabel
  2313 
  2304 
  2314     "Modified: / 07-02-2010 / 18:28:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2305     "Modified: / 07-02-2010 / 18:28:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2315     "Modified: / 08-02-2010 / 10:15:35 / Jan Vrany <jan,vrany@fit.cvut.cz>"
  2306     "Modified: / 08-02-2010 / 10:15:35 / Jan Vrany <jan,vrany@fit.cvut.cz>"
  2316     "Modified (format): / 06-06-2016 / 14:43:01 / cg"
  2307     "Modified (format): / 06-06-2016 / 14:43:01 / cg"
       
  2308     "Modified: / 17-09-2021 / 22:59:45 / Jan Vrany <jan.vrany@labware.com>"
  2317 !
  2309 !
  2318 
  2310 
  2319 label:aText
  2311 label:aText
  2320     label := aText.
  2312     label := aText.
  2321     realLabel := nil.
  2313     realLabel := nil.
  2459 
  2451 
  2460 version_CVS
  2452 version_CVS
  2461     ^ '$Header$'
  2453     ^ '$Header$'
  2462 !
  2454 !
  2463 
  2455 
       
  2456 version_HG
       
  2457 
       
  2458     ^ '$Changeset: <not expanded> $'
       
  2459 !
       
  2460 
  2464 version_SVN
  2461 version_SVN
  2465     ^ '$Id$'
  2462     ^ '$Id$'
  2466 ! !
  2463 ! !
  2467 
  2464 
  2468 
  2465