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