forked from pharo-project/pharo
/
DTTestsRunner.class.st
173 lines (152 loc) · 4.5 KB
/
DTTestsRunner.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
"
I am the plugin implementing test runner for DrTests.
"
Class {
#name : #DTTestsRunner,
#superclass : #DrTestsPlugin,
#category : #'DrTests-TestsRunner'
}
{ #category : #'api - accessing' }
DTTestsRunner class >> pluginName [
^ 'Tests Runner'
]
{ #category : #'api - accessing' }
DTTestsRunner class >> pluginResultClass [
^ DTTestsRunnerResult
]
{ #category : #'api - accessing' }
DTTestsRunner class >> weight [
^ 0
]
{ #category : #api }
DTTestsRunner >> allowMiniDrTests [
^ true
]
{ #category : #'configuration building' }
DTTestsRunner >> buildConfigurationFrom: aDrTests [
"Builds a configuration from the plugin by reading the information held by the UI (aDrTests)."
^ DTTestsRunnerConfiguration
items: aDrTests selectedItems
packages: aDrTests packagesSelected
]
{ #category : #api }
DTTestsRunner >> buildContextualMenuGroupWith: presenterIntance [
^ (CmCommandGroup named: 'TestRunnerResult context menu') asSpecGroup
description: 'Commands related to re-run a result.';
register:
(DTRerunCommand forSpec context: presenterIntance)
beHiddenWhenCantBeRun;
register:
(DTDebugTestCommand forSpec context: presenterIntance)
beHiddenWhenCantBeRun;
beDisplayedAsGroup;
yourself
]
{ #category : #api }
DTTestsRunner >> firstListLabel [
^ 'Packages'
]
{ #category : #api }
DTTestsRunner >> handleReRunResult: rerunnedResult forConfiguration: aDTRerunConfiguration [
| oldResult |
oldResult := self
removeTests: aDTRerunConfiguration configurationToRun items
from: aDTRerunConfiguration previousResult testsResult.
^ self pluginResultClass new
testsResult: (self joinTestResult: oldResult with: rerunnedResult testsResult);
yourself
]
{ #category : #private }
DTTestsRunner >> joinTestResult: aTestResult with: partialResult [
| newResult |
newResult := aTestResult.
partialResult passed do: [ :each | newResult addPass: each ].
partialResult errors do: [ :each | newResult addError: each ].
partialResult failures do: [ :each | newResult addFailure: each ].
partialResult skipped do: [ :each | newResult addSkip: each ].
^ newResult
]
{ #category : #tests }
DTTestsRunner >> label: aString forSuite: aTestSuite [
^ String streamContents: [ :stream |
stream nextPutAll: 'Running '; print: aTestSuite tests size; space; nextPutAll: aString.
aTestSuite tests size > 1 ifTrue: [ stream nextPut: $s ] ].
]
{ #category : #accessing }
DTTestsRunner >> pragmaForResultTrees [
^ #'dTTestRunnerResultTreeNamed:'
]
{ #category : #private }
DTTestsRunner >> removeTest: aTest from: aTestResult [
aTestResult
passed: (aTestResult passed copyWithout: aTest).
aTestResult
failures: (aTestResult failures copyWithout: aTest).
aTestResult
errors: (aTestResult errors copyWithout: aTest).
^ aTestResult
]
{ #category : #private }
DTTestsRunner >> removeTests: aCollectionOfTest from: aTestResult [
aCollectionOfTest do: [ :test |
self removeTest: test from: aTestResult ].
^ aTestResult
]
{ #category : #api }
DTTestsRunner >> resultButtonHelp [
^ 'Browse the test selected in the results list.' translated
]
{ #category : #api }
DTTestsRunner >> runForConfiguration: aDTpluginConfiguration [
| results |
results := self pluginResultClass new
testsResult: (self runTestSuites: { aDTpluginConfiguration asTestSuite });
yourself.
^ aDTpluginConfiguration handleResults: results for: self
]
{ #category : #private }
DTTestsRunner >> runSuite: aTestSuite withResult: aResult [
aTestSuite
when: TestAnnouncement
do: [ :testAnnouncement |
self flag: #TODO. "Dirty"
testAnnouncement test class = TestSuite
ifTrue: [ self announcer
announce:
(DTStatusUpdate
message: ('Running test {1}.' format: {testAnnouncement test name})) ] ].
[ aTestSuite run: aResult ]
ensure: [ aTestSuite unsubscribe: TestAnnouncement ]
]
{ #category : #private }
DTTestsRunner >> runTestSuites: testSuites [
|result|
result := TestAsserter classForTestResult new.
testSuites
do: [:testSuite | self runSuite: testSuite withResult: result ]
displayingProgress: 'Running Tests'.
^ result
]
{ #category : #api }
DTTestsRunner >> secondListLabel [
^ 'Tests Cases'
]
{ #category : #api }
DTTestsRunner >> startButtonHelp [
^ 'Run tests selected.' translated
]
{ #category : #api }
DTTestsRunner >> startButtonLabel [
^ 'Run Tests' translated
]
{ #category : #tests }
DTTestsRunner >> testSuiteOf: aSetOfTest withName: aString [
^ aSetOfTest
collect: [ :each |
TestSuite new
in: [ :suite |
suite
addTest: each;
name: (self label: aString forSuite: suite) ];
yourself ]
]