31 |
31 |
32 !RunUnitTests class methodsFor:'actions'! |
32 !RunUnitTests class methodsFor:'actions'! |
33 |
33 |
34 run |
34 run |
35 |doRunSpecificUnitTests unitTestSuiteName excludedUnitTestClassNames corruptedUnitTestClassNames |
35 |doRunSpecificUnitTests unitTestSuiteName excludedUnitTestClassNames corruptedUnitTestClassNames |
36 cmdArgs |
36 cmdArgs |
37 unitTestSuite |
37 unitTestSuite |
38 eachClassName eachClass |
38 eachClassName eachClass |
39 result| |
39 result| |
40 |
40 |
41 doRunSpecificUnitTests := false. |
41 doRunSpecificUnitTests := false. |
42 unitTestSuiteName := 'All Unit Tests'. |
42 unitTestSuiteName := 'All Unit Tests'. |
43 excludedUnitTestClassNames := self excludedUnitTestClassNamesForAll. |
43 excludedUnitTestClassNames := self excludedUnitTestClassNamesForAll. |
44 corruptedUnitTestClassNames := self corruptedUnitTestClassNames. |
44 corruptedUnitTestClassNames := self corruptedUnitTestClassNames. |
45 |
45 |
46 cmdArgs := Smalltalk commandLineArguments. |
46 cmdArgs := Smalltalk commandLineArguments. |
47 (cmdArgs includes:'--runOnlyExpeccoUnitTests') ifTrue:[ |
47 (cmdArgs includes:'--runOnlyExpeccoUnitTests') ifTrue:[ |
48 self logInfo:'configured to run expecco unit tests only'. |
48 self logInfo:'configured to run expecco unit tests only'. |
49 doRunSpecificUnitTests := true. |
49 doRunSpecificUnitTests := true. |
50 unitTestSuiteName := 'expecco Unit Tests'. |
50 unitTestSuiteName := 'expecco Unit Tests'. |
51 excludedUnitTestClassNames := self excludedUnitTestClassNamesForExpecco. |
51 excludedUnitTestClassNames := self excludedUnitTestClassNamesForExpecco. |
52 ]. |
52 ]. |
53 |
53 |
54 doRunSpecificUnitTests ifFalse:[ |
54 doRunSpecificUnitTests ifFalse:[ |
55 self logInfo:'configured to run all available unit tests'. |
55 self logInfo:'configured to run all available unit tests'. |
56 ]. |
56 ]. |
57 |
57 |
58 self logInfo:'collecting unit test classes to run'. |
58 self logInfo:'collecting unit test classes to run'. |
59 unitTestSuite := TestSuite named:unitTestSuiteName. |
59 unitTestSuite := TestSuite named:unitTestSuiteName. |
60 (Smalltalk at: #'stx_goodies_regression') classNamesAndAttributes do:[:eachClassNameAndAttributes | |
60 (Smalltalk at: #'stx_goodies_regression') classNamesAndAttributes do:[:eachClassNameAndAttributes | |
61 eachClassNameAndAttributes isSymbol ifTrue:[ |
61 eachClassNameAndAttributes isSymbol ifTrue:[ |
62 eachClassName := eachClassNameAndAttributes. |
62 eachClassName := eachClassNameAndAttributes. |
63 ] ifFalse:[ |
63 ] ifFalse:[ |
64 eachClassName := eachClassNameAndAttributes |
64 eachClassName := eachClassNameAndAttributes |
65 firstIfEmpty:nil. |
65 firstIfEmpty:nil. |
66 ]. |
66 ]. |
67 |
67 |
68 (corruptedUnitTestClassNames includes:eachClassName) ifTrue:[ |
68 (corruptedUnitTestClassNames includes:eachClassName) ifTrue:[ |
69 self |
69 self |
70 logWarning:('corrupted unit test class detected, please fix #%1' |
70 logWarning:('corrupted unit test class detected, please fix #%1' |
71 bindWith:eachClassName). |
71 bindWith:eachClassName). |
72 ] ifFalse:[ |
72 ] ifFalse:[ |
73 (excludedUnitTestClassNames includes:eachClassName) ifFalse:[ |
73 (excludedUnitTestClassNames includes:eachClassName) ifFalse:[ |
74 eachClassName notNil ifTrue:[ |
74 eachClassName notNil ifTrue:[ |
75 eachClass := Smalltalk |
75 eachClass := Smalltalk |
76 fileInClass:eachClassName |
76 fileInClass:eachClassName |
77 package:'stx:goodies/regression'. |
77 package:'stx:goodies/regression'. |
78 |
78 |
79 eachClass notNil ifTrue:[ |
79 eachClass notNil ifTrue:[ |
80 eachClass isTestCaseLike ifTrue:[ |
80 eachClass isTestCaseLike ifTrue:[ |
81 unitTestSuite addTest:eachClass suite. |
81 unitTestSuite addTest:eachClass suite. |
82 ]. |
82 ]. |
83 ]. |
83 ]. |
84 ]. |
84 ]. |
85 ]. |
85 ]. |
86 ]. |
86 ]. |
87 ]. |
87 ]. |
88 |
88 |
89 self |
89 self |
90 logInfo:('%1 unit test classes collected' |
90 logInfo:('%1 unit test classes collected' |
91 bindWith:unitTestSuite tests size). |
91 bindWith:unitTestSuite tests size). |
92 |
92 |
93 self logInfo:'starting unit tests'. |
93 self logInfo:'starting unit tests'. |
94 result := unitTestSuite |
94 result := unitTestSuite |
95 run:TestResultStX new |
95 run:TestResultStX new |
96 beforeEachDo:[:test | self logInfo:'performing unit test ', test printString] |
96 beforeEachDo:[:test | self logInfo:'performing unit test ', test printString] |
97 afterEachDo:[:test| ] |
97 afterEachDo:[:test| ] |
98 debug:(cmdArgs includes:'--debug'). |
98 debug:(cmdArgs includes:'--debug'). |
99 |
99 |
100 self logInfo:'generating report'. |
100 self logInfo:'generating report'. |
101 TestResultReporter |
101 TestResultReporter |
102 report:result |
102 report:result |
103 format:#xml_jUnit |
103 format:#xml_jUnit |
104 as:'testresult.xml'. |
104 as:'testresult.xml'. |
105 |
105 |
106 self logInfo:'summary:'. |
106 self logInfo:'summary:'. |
107 self logInfo:('%1 tests' bindWith:result runCount). |
107 self logInfo:('%1 tests' bindWith:result runCount). |
108 self logInfo:('%1 passed' bindWith:result passedCount). |
108 self logInfo:('%1 passed' bindWith:result passedCount). |
109 self logInfo:('%1 failed' bindWith:result failureCount). |
109 self logInfo:('%1 failed' bindWith:result failureCount). |
112 |
112 |
113 !RunUnitTests class methodsFor:'constants'! |
113 !RunUnitTests class methodsFor:'constants'! |
114 |
114 |
115 corruptedUnitTestClassNames |
115 corruptedUnitTestClassNames |
116 ^ #( |
116 ^ #( |
117 #'RegressionTests::ExternalInterfaceTests' |
117 #'RegressionTests::ExternalInterfaceTests' |
118 #'RegressionTests::Win32OLETests' |
118 #'RegressionTests::Win32OLETests' |
119 #'RegressionTests::HTTPServerTests' |
119 #'RegressionTests::HTTPServerTests' |
120 #'RegressionTests::SocketTests' |
120 #'RegressionTests::SocketTests' |
121 #'RegressionTests::DelayTest' |
121 #'RegressionTests::DelayTest' |
122 #'RegressionTests::ContextTest2' |
122 #'RegressionTests::ContextTest2' |
123 #'RegressionTests::DebuggerTest' |
123 #'RegressionTests::DebuggerTest' |
124 #'RegressionTests::OperatingSystem' |
124 #'RegressionTests::OperatingSystem' |
125 ) |
125 ) |
126 ! |
126 ! |
127 |
127 |
128 excludedUnitTestClassNamesForAll |
128 excludedUnitTestClassNamesForAll |
129 ^ #() |
129 ^ #() |
130 ! |
130 ! |
131 |
131 |
132 excludedUnitTestClassNamesForExpecco |
132 excludedUnitTestClassNamesForExpecco |
133 ^ self excludedUnitTestClassNamesForAll |
133 ^ self excludedUnitTestClassNamesForAll |
134 , #( |
134 , #( |
135 #'RegressionTests::BreakpointTests' |
135 #'RegressionTests::BreakpointTests' |
136 ) |
136 #'RegressionTests::SunitXMLOutputTest' |
|
137 ) |
137 ! ! |
138 ! ! |
138 |
139 |
139 !RunUnitTests class methodsFor:'logging'! |
140 !RunUnitTests class methodsFor:'logging'! |
140 |
141 |
141 log:aString |
142 log:aString |
142 type:aType |
143 type:aType |
143 |
144 |
144 Stdout |
145 Stdout |
145 showCR:('%1 [%2] : %3' |
146 showCR:('%1 [%2] : %3' |
146 bindWith:Timestamp now printString |
147 bindWith:Timestamp now printString |
147 with:(aType printString asLowercase paddedTo:'warning' size) |
148 with:(aType printString asLowercase paddedTo:'warning' size) |
148 with:aString). |
149 with:aString). |
149 ! |
150 ! |
150 |
151 |
151 logInfo:aString |
152 logInfo:aString |
152 self |
153 self |
153 log:aString |
154 log:aString |
154 type:'INFO' |
155 type:'INFO' |
155 ! |
156 ! |
156 |
157 |
157 logWarning:aString |
158 logWarning:aString |
158 self |
159 self |
159 log:aString |
160 log:aString |
160 type:'WARNING' |
161 type:'WARNING' |
161 ! ! |
162 ! ! |
162 |
|