@@ -19,6 +19,7 @@ public void reportScoverage() {
19
19
result .assertTaskExists (ScoveragePlugin .getREPORT_NAME ());
20
20
result .assertTaskExists ("a:" + ScoveragePlugin .getREPORT_NAME ());
21
21
result .assertTaskExists ("b:" + ScoveragePlugin .getREPORT_NAME ());
22
+ result .assertTaskExists ("common:" + ScoveragePlugin .getREPORT_NAME ());
22
23
}
23
24
24
25
@ Test
@@ -29,6 +30,7 @@ public void reportScoverageOnlyRoot() {
29
30
result .assertTaskExists (ScoveragePlugin .getREPORT_NAME ());
30
31
result .assertTaskDoesntExist ("a:" + ScoveragePlugin .getREPORT_NAME ());
31
32
result .assertTaskDoesntExist ("b:" + ScoveragePlugin .getREPORT_NAME ());
33
+ result .assertTaskDoesntExist ("common:" + ScoveragePlugin .getREPORT_NAME ());
32
34
}
33
35
34
36
@ Test
@@ -39,6 +41,7 @@ public void reportScoverageOnlyA() {
39
41
result .assertTaskDoesntExist (ScoveragePlugin .getREPORT_NAME ());
40
42
result .assertTaskExists ("a:" + ScoveragePlugin .getREPORT_NAME ());
41
43
result .assertTaskDoesntExist ("b:" + ScoveragePlugin .getREPORT_NAME ());
44
+ result .assertTaskDoesntExist ("common:" + ScoveragePlugin .getREPORT_NAME ());
42
45
}
43
46
44
47
@ Test
@@ -50,6 +53,7 @@ public void aggregateScoverage() {
50
53
result .assertTaskExists ("a:" + ScoveragePlugin .getREPORT_NAME ());
51
54
result .assertTaskExists ("b:" + ScoveragePlugin .getREPORT_NAME ());
52
55
result .assertTaskExists (ScoveragePlugin .getAGGREGATE_NAME ());
56
+ result .assertTaskExists ("common:" + ScoveragePlugin .getREPORT_NAME ());
53
57
}
54
58
55
59
@ Test
@@ -60,9 +64,11 @@ public void checkScoverage() {
60
64
result .assertTaskExists (ScoveragePlugin .getREPORT_NAME ());
61
65
result .assertTaskExists ("a:" + ScoveragePlugin .getREPORT_NAME ());
62
66
result .assertTaskExists ("b:" + ScoveragePlugin .getREPORT_NAME ());
67
+ result .assertTaskExists ("common:" + ScoveragePlugin .getREPORT_NAME ());
63
68
result .assertTaskExists (ScoveragePlugin .getCHECK_NAME ());
64
69
result .assertTaskExists ("a:" + ScoveragePlugin .getCHECK_NAME ());
65
70
result .assertTaskExists ("b:" + ScoveragePlugin .getCHECK_NAME ());
71
+ result .assertTaskExists ("common:" + ScoveragePlugin .getCHECK_NAME ());
66
72
result .assertTaskDoesntExist (ScoveragePlugin .getAGGREGATE_NAME ());
67
73
}
68
74
@@ -88,9 +94,11 @@ public void checkScoverageOnlyA() {
88
94
result .assertTaskDoesntExist (ScoveragePlugin .getREPORT_NAME ());
89
95
result .assertTaskExists ("a:" + ScoveragePlugin .getREPORT_NAME ());
90
96
result .assertTaskDoesntExist ("b:" + ScoveragePlugin .getREPORT_NAME ());
97
+ result .assertTaskDoesntExist ("common:" + ScoveragePlugin .getREPORT_NAME ());
91
98
result .assertTaskDoesntExist (ScoveragePlugin .getCHECK_NAME ());
92
99
result .assertTaskExists ("a:" + ScoveragePlugin .getCHECK_NAME ());
93
100
result .assertTaskDoesntExist ("b:" + ScoveragePlugin .getCHECK_NAME ());
101
+ result .assertTaskDoesntExist ("common:" + ScoveragePlugin .getCHECK_NAME ());
94
102
result .assertTaskDoesntExist (ScoveragePlugin .getAGGREGATE_NAME ());
95
103
}
96
104
@@ -103,9 +111,11 @@ public void checkAndAggregateScoverage() throws Exception {
103
111
result .assertTaskSucceeded (ScoveragePlugin .getREPORT_NAME ());
104
112
result .assertTaskSucceeded ("a:" + ScoveragePlugin .getREPORT_NAME ());
105
113
result .assertTaskSucceeded ("b:" + ScoveragePlugin .getREPORT_NAME ());
114
+ result .assertTaskSucceeded ("common:" + ScoveragePlugin .getREPORT_NAME ());
106
115
result .assertTaskSucceeded (ScoveragePlugin .getCHECK_NAME ());
107
116
result .assertTaskSucceeded ("a:" + ScoveragePlugin .getCHECK_NAME ());
108
117
result .assertTaskSucceeded ("b:" + ScoveragePlugin .getCHECK_NAME ());
118
+ result .assertTaskSucceeded ("common:" + ScoveragePlugin .getCHECK_NAME ());
109
119
result .assertTaskSucceeded (ScoveragePlugin .getAGGREGATE_NAME ());
110
120
111
121
assertAllReportFilesExist ();
@@ -119,7 +129,8 @@ public void checkScoverageWithoutCoverageInRoot() throws Exception {
119
129
"test" ,
120
130
"--tests" , "org.hello.TestNothingSuite" ,
121
131
"--tests" , "org.hello.a.WorldASuite" ,
122
- "--tests" , "org.hello.b.WorldBSuite" );
132
+ "--tests" , "org.hello.b.WorldBSuite" ,
133
+ "--tests" , "org.hello.common.WorldCommonSuite" );
123
134
124
135
result .assertTaskFailed (ScoveragePlugin .getCHECK_NAME ());
125
136
@@ -134,14 +145,30 @@ public void checkScoverageWithoutCoverageInA() throws Exception {
134
145
"test" ,
135
146
"--tests" , "org.hello.a.TestNothingASuite" ,
136
147
"--tests" , "org.hello.WorldSuite" ,
137
- "--tests" , "org.hello.b.WorldBSuite" );
148
+ "--tests" , "org.hello.b.WorldBSuite" ,
149
+ "--tests" , "org.hello.common.WorldCommonSuite" );
138
150
139
151
result .assertTaskFailed ("a:" + ScoveragePlugin .getCHECK_NAME ());
140
152
141
153
assertAReportFilesExist ();
142
154
assertCoverage (0.0 , reportDir (projectDir ().toPath ().resolve ("a" ).toFile ()));
143
155
}
144
156
157
+ @ Test
158
+ public void checkScoverageWithoutNormalCompilationAndWithoutCoverageInCommon () throws Exception {
159
+
160
+ AssertableBuildResult result = runAndFail ("clean" ,
161
+ ":a:test" ,
162
+ ":common:test" , "--tests" , "org.hello.common.TestNothingCommonSuite" ,
163
+ "-x" , "compileScala" ,
164
+ ScoveragePlugin .getCHECK_NAME ());
165
+
166
+ result .assertTaskFailed ("common:" + ScoveragePlugin .getCHECK_NAME ());
167
+
168
+ assertCommonReportFilesExist ();
169
+ assertCoverage (0.0 , reportDir (projectDir ().toPath ().resolve ("common" ).toFile ()));
170
+ }
171
+
145
172
@ Test
146
173
public void checkAndAggregateScoverageWithoutCoverageInRoot () throws Exception {
147
174
@@ -151,18 +178,21 @@ public void checkAndAggregateScoverageWithoutCoverageInRoot() throws Exception {
151
178
ScoveragePlugin .getAGGREGATE_NAME (), "test" ,
152
179
"--tests" , "org.hello.TestNothingSuite" ,
153
180
"--tests" , "org.hello.a.WorldASuite" ,
154
- "--tests" , "org.hello.b.WorldBSuite" );
181
+ "--tests" , "org.hello.b.WorldBSuite" ,
182
+ "--tests" , "org.hello.common.WorldCommonSuite" );
155
183
156
184
result .assertTaskSucceeded (ScoveragePlugin .getREPORT_NAME ());
157
185
result .assertTaskSucceeded ("a:" + ScoveragePlugin .getREPORT_NAME ());
158
186
result .assertTaskSucceeded ("b:" + ScoveragePlugin .getREPORT_NAME ());
187
+ result .assertTaskSucceeded ("common:" + ScoveragePlugin .getREPORT_NAME ());
159
188
result .assertTaskSucceeded (ScoveragePlugin .getCHECK_NAME ());
160
189
result .assertTaskSucceeded ("a:" + ScoveragePlugin .getCHECK_NAME ());
161
190
result .assertTaskSucceeded ("b:" + ScoveragePlugin .getCHECK_NAME ());
191
+ result .assertTaskSucceeded ("common:" + ScoveragePlugin .getCHECK_NAME ());
162
192
result .assertTaskSucceeded (ScoveragePlugin .getAGGREGATE_NAME ());
163
193
164
194
assertAllReportFilesExist ();
165
- assertCoverage (66.6 );
195
+ assertCoverage (87.5 );
166
196
}
167
197
168
198
@ Test
@@ -172,31 +202,67 @@ public void checkAndAggregateScoverageWithoutCoverageInAll() throws Exception {
172
202
ScoveragePlugin .getAGGREGATE_NAME (), "test" ,
173
203
"--tests" , "org.hello.TestNothingSuite" ,
174
204
"--tests" , "org.hello.a.TestNothingASuite" ,
175
- "--tests" , "org.hello.b.TestNothingBSuite" );
205
+ "--tests" , "org.hello.b.TestNothingBSuite" ,
206
+ "--tests" , "org.hello.common.TestNothingCommonSuite" );
176
207
177
208
result .assertTaskSucceeded (ScoveragePlugin .getREPORT_NAME ());
178
209
result .assertTaskSucceeded ("a:" + ScoveragePlugin .getREPORT_NAME ());
179
210
result .assertTaskSucceeded ("b:" + ScoveragePlugin .getREPORT_NAME ());
211
+ result .assertTaskSucceeded ("common:" + ScoveragePlugin .getREPORT_NAME ());
180
212
result .assertTaskSucceeded (ScoveragePlugin .getAGGREGATE_NAME ());
181
213
result .assertTaskFailed (ScoveragePlugin .getCHECK_NAME ());
182
214
183
215
assertAllReportFilesExist ();
184
216
assertCoverage (0.0 );
185
217
}
186
218
219
+ @ Test
220
+ public void aggregateScoverageWithoutNormalCompilation () throws Exception {
221
+
222
+ AssertableBuildResult result = run ("clean" , ScoveragePlugin .getAGGREGATE_NAME (),
223
+ "-x" , "compileScala" );
224
+
225
+ result .assertTaskSkipped ("compileScala" );
226
+ result .assertTaskSkipped ("a:compileScala" );
227
+ result .assertTaskSkipped ("b:compileScala" );
228
+ result .assertTaskSkipped ("common:compileScala" );
229
+ result .assertTaskSucceeded (ScoveragePlugin .getCOMPILE_NAME ());
230
+ result .assertTaskSucceeded ("a:" + ScoveragePlugin .getCOMPILE_NAME ());
231
+ result .assertTaskSucceeded ("b:" + ScoveragePlugin .getCOMPILE_NAME ());
232
+ result .assertTaskSucceeded ("common:" + ScoveragePlugin .getCOMPILE_NAME ());
233
+ result .assertTaskSucceeded (ScoveragePlugin .getREPORT_NAME ());
234
+ result .assertTaskSucceeded ("a:" + ScoveragePlugin .getREPORT_NAME ());
235
+ result .assertTaskSucceeded ("b:" + ScoveragePlugin .getREPORT_NAME ());
236
+ result .assertTaskSucceeded ("common:" + ScoveragePlugin .getREPORT_NAME ());
237
+ result .assertTaskSucceeded (ScoveragePlugin .getAGGREGATE_NAME ());
238
+
239
+ assertAllReportFilesExist ();
240
+ assertCoverage (100.0 );
241
+
242
+ Assert .assertTrue (resolve (buildDir (resolve (projectDir (), "a" )), "classes/scala/main/org/hello/a/WorldA.class" ).exists ());
243
+ Assert .assertFalse (resolve (buildDir (resolve (projectDir (), "a" )), "classes/scala/scoverage/org/hello/a/WorldA.class" ).exists ());
244
+
245
+ Assert .assertTrue (resolve (buildDir (resolve (projectDir (), "b" )), "classes/scala/main/org/hello/b/WorldB.class" ).exists ());
246
+ Assert .assertFalse (resolve (buildDir (resolve (projectDir (), "b" )), "classes/scala/scoverage/org/hello/b/WorldB.class" ).exists ());
247
+
248
+ Assert .assertTrue (resolve (buildDir (resolve (projectDir (), "common" )), "classes/scala/main/org/hello/common/WorldCommon.class" ).exists ());
249
+ Assert .assertFalse (resolve (buildDir (resolve (projectDir (), "common" )), "classes/scala/scoverage/org/hello/common/WorldCommon.class" ).exists ());
250
+ }
251
+
187
252
private void assertAllReportFilesExist () {
188
253
189
254
assertRootReportFilesExist ();
190
255
assertAReportFilesExist ();
191
256
assertBReportFilesExist ();
257
+ assertCommonReportFilesExist ();
192
258
assertAggregationFilesExist ();
193
259
}
194
260
195
261
private void assertAggregationFilesExist () {
196
262
197
- assertRootReportFilesExist ();
198
263
Assert .assertTrue (resolve (reportDir (), "a/src/main/scala/org/hello/a/WorldA.scala.html" ).exists ());
199
264
Assert .assertTrue (resolve (reportDir (), "b/src/main/scala/org/hello/b/WorldB.scala.html" ).exists ());
265
+ Assert .assertTrue (resolve (reportDir (), "common/src/main/scala/org/hello/common/WorldCommon.scala.html" ).exists ());
200
266
}
201
267
202
268
private void assertRootReportFilesExist () {
@@ -207,16 +273,22 @@ private void assertRootReportFilesExist() {
207
273
208
274
private void assertAReportFilesExist () {
209
275
210
- File aReportDir = reportDir (projectDir ().toPath ().resolve ("a" ).toFile ());
211
- Assert .assertTrue (resolve (aReportDir , "index.html" ).exists ());
212
- Assert .assertTrue (resolve (aReportDir , "src/main/scala/org/hello/a/WorldA.scala.html" ).exists ());
276
+ File reportDir = reportDir (projectDir ().toPath ().resolve ("a" ).toFile ());
277
+ Assert .assertTrue (resolve (reportDir , "index.html" ).exists ());
278
+ Assert .assertTrue (resolve (reportDir , "src/main/scala/org/hello/a/WorldA.scala.html" ).exists ());
213
279
}
214
280
215
281
private void assertBReportFilesExist () {
216
282
217
- File bReportDir = reportDir (projectDir ().toPath ().resolve ("b" ).toFile ());
218
- Assert .assertTrue (resolve (bReportDir , "index.html" ).exists ());
219
- Assert .assertTrue (resolve (bReportDir , "src/main/scala/org/hello/b/WorldB.scala.html" ).exists ());
283
+ File reportDir = reportDir (projectDir ().toPath ().resolve ("b" ).toFile ());
284
+ Assert .assertTrue (resolve (reportDir , "index.html" ).exists ());
285
+ Assert .assertTrue (resolve (reportDir , "src/main/scala/org/hello/b/WorldB.scala.html" ).exists ());
286
+ }
287
+
288
+ private void assertCommonReportFilesExist () {
220
289
290
+ File reportDir = reportDir (projectDir ().toPath ().resolve ("common" ).toFile ());
291
+ Assert .assertTrue (resolve (reportDir , "index.html" ).exists ());
292
+ Assert .assertTrue (resolve (reportDir , "src/main/scala/org/hello/common/WorldCommon.scala.html" ).exists ());
221
293
}
222
294
}
0 commit comments