Skip to content

Commit 424afa3

Browse files
committed
Merge pull request #167 from lustefaniak/scalajs-support-tests
sbt-test to verify that scala.js is supported by scoverage
2 parents 85dd15c + b10b0ae commit 424afa3

File tree

7 files changed

+75
-0
lines changed

7 files changed

+75
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
lazy val root = (project in file(".")).aggregate(crossJS, crossJVM)
2+
3+
lazy val cross = crossProject.in(file("sjstest")).settings(
4+
scalaVersion := "2.11.7",
5+
libraryDependencies ++= Seq(
6+
"org.scalatest" %%% "scalatest" % "3.0.0-M15" % "test"
7+
)
8+
)
9+
10+
11+
lazy val crossJS = cross.js
12+
lazy val crossJVM = cross.jvm
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// The Typesafe repository
2+
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
3+
4+
//scoverage needs this
5+
resolvers += Classpaths.sbtPluginReleases
6+
7+
{
8+
val pluginVersion = System.getProperty("plugin.version")
9+
if(pluginVersion == null)
10+
throw new RuntimeException("""|The system property 'plugin.version' is not defined.
11+
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
12+
else addSbtPlugin("org.scoverage" %% "sbt-scoverage" % pluginVersion)
13+
}
14+
15+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.8")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import org.scalatest.{FlatSpec, Matchers}
2+
3+
class JsTest extends FlatSpec with Matchers {
4+
5+
"JS UnderTest" should "work on JS" in {
6+
UnderTest.jsMethod shouldBe "js"
7+
}
8+
9+
}
10+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import org.scalatest.{FlatSpec, Matchers}
2+
3+
class JvmTest extends FlatSpec with Matchers {
4+
5+
"JVM UnderTest" should "work on JVM" in {
6+
UnderTest.jvmMethod shouldBe "jvm"
7+
}
8+
9+
}
10+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
object UnderTest {
3+
def onJsAndJvm: String = "js and jvm"
4+
5+
def jsMethod: String = "js"
6+
7+
def jvmMethod: String = "jvm"
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import org.scalatest.{FlatSpec, Matchers}
2+
3+
class SharedTest extends FlatSpec with Matchers {
4+
5+
"Shared UnderTest" should "return where it works" in {
6+
UnderTest.onJsAndJvm shouldBe "js and jvm"
7+
}
8+
9+
}

src/sbt-test/scoverage/scalajs/test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# run scoverage using the coverage task
2+
> clean
3+
> coverage
4+
> test
5+
# There should be scoverage-data directory
6+
$ exists sjstest/js/target/scala-2.11/scoverage-data
7+
$ exists sjstest/jvm/target/scala-2.11/scoverage-data
8+
> coverageReport
9+
# There should be scoverage-report directory
10+
$ exists sjstest/js/target/scala-2.11/scoverage-report
11+
$ exists sjstest/jvm/target/scala-2.11/scoverage-report

0 commit comments

Comments
 (0)