-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathScalaSingleMultiLangModuleTest.java
145 lines (105 loc) · 6.04 KB
/
ScalaSingleMultiLangModuleTest.java
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
package org.scoverage;
import org.junit.Assert;
import org.junit.Test;
public class ScalaSingleMultiLangModuleTest extends ScoverageFunctionalTest {
public ScalaSingleMultiLangModuleTest() { super("scala-single-multi-lang-module"); }
@Test
public void test() {
AssertableBuildResult result = dryRun("clean", "test");
result.assertTaskDoesntExist(ScoveragePlugin.getCOMPILE_NAME());
result.assertTaskDoesntExist(ScoveragePlugin.getREPORT_NAME());
result.assertTaskDoesntExist(ScoveragePlugin.getAGGREGATE_NAME());
result.assertTaskDoesntExist(ScoveragePlugin.getCHECK_NAME());
}
@Test
public void build() {
AssertableBuildResult result = dryRun("clean", "build");
result.assertTaskDoesntExist(ScoveragePlugin.getCOMPILE_NAME());
result.assertTaskDoesntExist(ScoveragePlugin.getREPORT_NAME());
result.assertTaskDoesntExist(ScoveragePlugin.getAGGREGATE_NAME());
result.assertTaskDoesntExist(ScoveragePlugin.getCHECK_NAME());
}
@Test
public void reportScoverage() {
AssertableBuildResult result = dryRun("clean", ScoveragePlugin.getREPORT_NAME());
result.assertTaskExists(ScoveragePlugin.getCOMPILE_NAME());
result.assertTaskExists(ScoveragePlugin.getREPORT_NAME());
result.assertTaskDoesntExist(ScoveragePlugin.getAGGREGATE_NAME());
result.assertTaskDoesntExist(ScoveragePlugin.getCHECK_NAME());
}
@Test
public void aggregateScoverage() {
AssertableBuildResult result = runAndFail("clean", ScoveragePlugin.getAGGREGATE_NAME());
result.assertNoTasks();
}
@Test
public void checkScoverage() throws Exception {
AssertableBuildResult result = run("clean", ScoveragePlugin.getCHECK_NAME());
result.assertTaskSucceeded(ScoveragePlugin.getCOMPILE_NAME());
result.assertTaskSucceeded(ScoveragePlugin.getREPORT_NAME());
result.assertTaskSucceeded(ScoveragePlugin.getCHECK_NAME());
result.assertTaskDoesntExist(ScoveragePlugin.getAGGREGATE_NAME());
assertReportFilesExist();
assertCoverage(66.7);
}
@Test
public void checkScoverageFails() throws Exception {
AssertableBuildResult result = runAndFail("clean", ScoveragePlugin.getCHECK_NAME(),
"test", "--tests", "org.hello.TestNothingSuite");
result.assertTaskSucceeded(ScoveragePlugin.getCOMPILE_NAME());
result.assertTaskSucceeded(ScoveragePlugin.getREPORT_NAME());
result.assertTaskFailed(ScoveragePlugin.getCHECK_NAME());
result.assertTaskDoesntExist(ScoveragePlugin.getAGGREGATE_NAME());
assertReportFilesExist();
assertCoverage(0.0);
}
@Test
public void reportScoverageWithExcludedClasses() throws Exception {
AssertableBuildResult result = run("clean", ScoveragePlugin.getREPORT_NAME(),
"-PexcludedFile=.*");
result.assertTaskSucceeded(ScoveragePlugin.getCOMPILE_NAME());
result.assertTaskSucceeded(ScoveragePlugin.getREPORT_NAME());
result.assertTaskDoesntExist(ScoveragePlugin.getCHECK_NAME());
result.assertTaskDoesntExist(ScoveragePlugin.getAGGREGATE_NAME());
Assert.assertTrue(resolve(reportDir(), "index.html").exists());
Assert.assertFalse(resolve(reportDir(), "src/main/scala/org/hello/World.scala.html").exists());
assertCoverage(100.0); // coverage is 100 since no classes are covered
// compiled class should exist in the default classes directory, but not in scoverage
Assert.assertTrue(resolve(buildDir(), "classes/scala/main/org/hello/World.class").exists());
Assert.assertFalse(resolve(buildDir(), "classes/scala/scoverage/org/hello/World.class").exists());
}
@Test
public void reportScoverageWithoutNormalCompilation() throws Exception {
AssertableBuildResult result = run("clean", ScoveragePlugin.getREPORT_NAME(),
"-x", "compileScala");
result.assertTaskSkipped("compileScala");
result.assertTaskSucceeded(ScoveragePlugin.getCOMPILE_NAME());
result.assertTaskSucceeded(ScoveragePlugin.getREPORT_NAME());
result.assertTaskDoesntExist(ScoveragePlugin.getCHECK_NAME());
result.assertTaskDoesntExist(ScoveragePlugin.getAGGREGATE_NAME());
assertReportFilesExist();
assertCoverage(66.7);
Assert.assertTrue(resolve(reportDir(), "index.html").exists());
Assert.assertTrue(resolve(reportDir(), "src/main/scala/org/hello/World.scala.html").exists());
Assert.assertFalse(resolve(reportDir(), "src/main/java/org/hello/JavaWorld.java.html").exists());
Assert.assertTrue(resolve(buildDir(), "classes/java/main/org/hello/JavaWorld.class").exists());
Assert.assertTrue(resolve(buildDir(), "classes/java/scoverage/org/hello/JavaWorld.class").exists());
Assert.assertTrue(resolve(buildDir(), "classes/scala/main/org/hello/World.class").exists());
Assert.assertFalse(resolve(buildDir(), "classes/scala/scoverage/org/hello/World.class").exists());
}
@Test
public void reportScoverageWithoutNormalCompilationAndWithExcludedClasses() throws Exception {
AssertableBuildResult result = run("clean", ScoveragePlugin.getREPORT_NAME(),
"-PexcludedFile=.*", "-x", "compileScala");
Assert.assertTrue(resolve(reportDir(), "index.html").exists());
Assert.assertFalse(resolve(reportDir(), "src/main/scala/org/hello/World.scala.html").exists());
assertCoverage(100.0); // coverage is 100 since no classes are covered
// compiled class should exist in the default classes directory, but not in scoverage
Assert.assertTrue(resolve(buildDir(), "classes/scala/main/org/hello/World.class").exists());
Assert.assertFalse(resolve(buildDir(), "classes/scala/scoverage/org/hello/World.class").exists());
}
private void assertReportFilesExist() {
Assert.assertTrue(resolve(reportDir(), "index.html").exists());
Assert.assertTrue(resolve(reportDir(), "src/main/scala/org/hello/World.scala.html").exists());
}
}