Skip to content

Commit d44d55f

Browse files
committed
Add exclusion tests
1 parent 2644e30 commit d44d55f

12 files changed

+167
-0
lines changed
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
invoker.goals=clean verify site -e -ntp

src/it/test_exclusion/pom.xml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>it.scoverage-maven-plugin</groupId>
9+
<artifactId>integration_tests_parent</artifactId>
10+
<version>1.0-SNAPSHOT</version>
11+
<relativePath>../integration_tests_parent/pom.xml</relativePath>
12+
</parent>
13+
14+
<artifactId>test_exclusion</artifactId>
15+
<version>1.0-SNAPSHOT</version>
16+
<packaging>jar</packaging>
17+
<name>Test Scoverage exclusion</name>
18+
<description>Test Scoverage exclusion</description>
19+
20+
<properties>
21+
<!-- won't work with Scala 3, as it doesn't support exclusions yet -->
22+
<scala.compat.version>2.13</scala.compat.version>
23+
<scala.minor.version>12</scala.minor.version>
24+
</properties>
25+
26+
<build>
27+
<plugins>
28+
<plugin>
29+
<groupId>org.apache.maven.plugins</groupId>
30+
<artifactId>maven-compiler-plugin</artifactId>
31+
</plugin>
32+
<plugin>
33+
<groupId>net.alchim31.maven</groupId>
34+
<artifactId>scala-maven-plugin</artifactId>
35+
</plugin>
36+
<plugin>
37+
<groupId>org.scalatest</groupId>
38+
<artifactId>scalatest-maven-plugin</artifactId>
39+
</plugin>
40+
<plugin>
41+
<groupId>@project.groupId@</groupId>
42+
<artifactId>@project.artifactId@</artifactId>
43+
<configuration>
44+
<excludedPackages>.*package02.*;.*package05</excludedPackages>
45+
<excludedFiles>.*Package03HelloService.*;.*Package03ByeService</excludedFiles>
46+
</configuration>
47+
</plugin>
48+
</plugins>
49+
</build>
50+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.package01
2+
3+
object Package01HelloService {
4+
5+
// gonna be included in coverage report
6+
def hello: String = "Hello from package01"
7+
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// gonna be excluded from coverage report by package exclusion
2+
package org.package02.nested02
3+
4+
object ImGonnaBeExcludedCauseImInPackage02Nested02 {
5+
6+
def hello: String = "Hello from package02.nested02"
7+
8+
}
9+
10+
object SameStoryBro {
11+
12+
def hello: String = "Hello from package02.nested02 again"
13+
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// gonna be excluded from coverage report by package exclusion
2+
package org.package02
3+
4+
object ImGonnaBeExcludedCauseImInPackage02 {
5+
6+
def hello: String = "Hello from package02"
7+
8+
}
9+
10+
object SameStoryBro {
11+
12+
def hello: String = "Hello from package02 again"
13+
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.package03
2+
3+
object Package03ByeService {
4+
5+
// gonna be excluded from coverage report by file exclusion
6+
def bye: String = "Bye from package03"
7+
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.package03
2+
3+
object Package03HelloService1 {
4+
5+
// gonna be excluded from coverage report by file exclusion
6+
def hello: String = "Hello from package03 service 1"
7+
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.package03
2+
3+
object Package03HelloService2 {
4+
5+
// gonna be excluded from coverage report by file exclusion
6+
def hello: String = "Hello from package03 service 2"
7+
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.package04
2+
3+
object Package04HelloService {
4+
5+
// gonna be excluded from coverage report by code comments below
6+
7+
// $COVERAGE-OFF$
8+
def hello: String = "Hello from package04"
9+
// $COVERAGE-ON$
10+
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// gonna be excluded from coverage report by package exclusion
2+
package org.package05
3+
4+
object ImGonnaBeExcludedCauseImInPackage05 {
5+
6+
def hello: String = "Hello from package05"
7+
8+
}
9+
10+
object SameStoryBro {
11+
12+
def hello: String = "Hello from package05 again"
13+
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.package01
2+
3+
import org.scalatest.wordspec.AnyWordSpec
4+
5+
class Package01HelloServiceTest extends AnyWordSpec {
6+
7+
"Package01HelloService" should {
8+
"say hello" in {
9+
assert(Package01HelloService.hello == "Hello from package01")
10+
}
11+
}
12+
}

src/it/test_exclusion/validate.groovy

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
try {
2+
3+
def logFile = new File(basedir, "build.log")
4+
def lines = logFile.readLines()
5+
assert lines.contains("[INFO] Statement coverage.: 100.00%")
6+
assert lines.contains("[INFO] Branch coverage....: 100.00%")
7+
8+
def scoverageFile = new File(basedir, "target/scoverage.xml")
9+
assert scoverageFile.exists()
10+
11+
def reportFile = new File(basedir, "target/site/scoverage/index.html")
12+
assert reportFile.exists()
13+
14+
return true
15+
16+
} catch (Throwable e) {
17+
e.printStackTrace()
18+
return false
19+
}

0 commit comments

Comments
 (0)