Skip to content

Commit c66bb08

Browse files
committed
Add scripted test with unmanaged sources
1 parent bdbf96b commit c66bb08

File tree

6 files changed

+52
-0
lines changed

6 files changed

+52
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name := "jacocoTest"
2+
organization := "com.navetas"
3+
4+
scalaVersion := "2.10.4"
5+
scalacOptions ++= Seq("-deprecation", "-optimize", "-unchecked", "-Xlint", "-language:_")
6+
7+
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.4" % "test"
8+
9+
unmanagedResourceDirectories in Compile += sourceDirectory.value / "unmanaged"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
val pluginVersion = System.getProperty("plugin.version")
3+
if (pluginVersion == null)
4+
throw new RuntimeException("""|The system property 'plugin.version' is not defined.
5+
|Specify this property using the parameter -Dplugin.version=<version>""".stripMargin)
6+
7+
else addSbtPlugin("com.github.sbt" % "sbt-jacoco" % pluginVersion)
8+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package jacocotest
2+
3+
import java.{util => ju}
4+
5+
object PropertyUtils {
6+
private val props = new ju.Properties()
7+
props.load(getClass.getResourceAsStream("/info.properties"))
8+
9+
def getFoo(): Int = {
10+
props.getProperty("foo").toInt
11+
}
12+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package jacocotest
2+
3+
import org.scalatest.{FlatSpec, Matchers}
4+
5+
class PropertyUtilsSpec extends FlatSpec with Matchers {
6+
"PropertyUtils" should "load foo" in {
7+
PropertyUtils.getFoo() shouldBe 182
8+
}
9+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
foo=182
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
> clean
2+
3+
# coverage should pass
4+
> jacoco
5+
6+
# instrumented classes
7+
$ exists target/scala-2.10/jacoco/instrumented-classes
8+
9+
# results
10+
$ exists target/scala-2.10/jacoco/data/jacoco.exec
11+
12+
# html report
13+
$ exists target/scala-2.10/jacoco/report/html/index.html

0 commit comments

Comments
 (0)