Skip to content

Commit 6225254

Browse files
committedMay 7, 2021
Update tests in scripted.
Normally I wouldn't have updated these, but since specs2 changed namespaces and I needed to go through and change everything since the current one wasn't published for newer versions of Scala. Therefore I just opted to migrate to a newer testframework that I do know will continue to be supported. I also then bumped the Scala versions in the actual tests.
1 parent 17e2575 commit 6225254

File tree

23 files changed

+137
-151
lines changed

23 files changed

+137
-151
lines changed
 
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
/*
22
The projects test aggregation of coverage reports from two sub-projects.
33
The sub-projects are in the directories partA and partB.
4-
*/
4+
*/
55

66
lazy val commonSettings = Seq(
77
organization := "org.scoverage",
88
version := "0.1.0",
9-
scalaVersion := "2.12.13"
9+
scalaVersion := "2.13.5"
1010
)
1111

12-
lazy val specs2Lib = "org.specs2" %% "specs2" % "2.5" % "test"
13-
1412
def module(name: String) = {
1513
val id = s"part$name"
1614
Project(id = id, base = file(id))
1715
.settings(commonSettings: _*)
1816
.settings(
1917
Keys.name := name,
20-
libraryDependencies += specs2Lib
18+
libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
2119
)
2220
}
2321

2422
lazy val partA = module("A")
2523
lazy val partB = module("B")
2624

2725
lazy val root = (project in file("."))
28-
.settings(commonSettings:_*)
26+
.settings(commonSettings: _*)
2927
.settings(
3028
name := "root",
31-
test := { }
32-
).aggregate(
29+
test := {}
30+
)
31+
.aggregate(
3332
partA,
3433
partB
3534
)
3635

3736
ThisBuild / resolvers ++= {
38-
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots"))
37+
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT")))
38+
Seq(Resolver.sonatypeRepo("snapshots"))
3939
else Seq.empty
4040
}
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
import org.specs2.mutable._
1+
import munit.FunSuite
22
import org.scoverage.issue53.part.a.AdderScala
33

4-
/**
5-
* Created by Mikhail Kokho on 7/10/2015.
6-
*/
7-
class AdderTestSuite extends Specification {
8-
"Adder" should {
9-
"sum two numbers" in {
10-
AdderScala.add(1, 2) mustEqual 3
11-
}
4+
/** Created by Mikhail Kokho on 7/10/2015.
5+
*/
6+
class AdderTestSuite extends FunSuite {
7+
test("Adder should sum two numbers") {
8+
assertEquals(AdderScala.add(1, 2), 3)
129
}
1310
}
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
import org.specs2.mutable._
1+
import munit.FunSuite
22
import org.scoverage.issue53.part.b.SubtractorScala
33

4-
/**
5-
* Created by Mikhail Kokho on 7/10/2015.
6-
*/
7-
class SubtractorTestSuite extends Specification {
8-
"Subtractor" should {
9-
"subtract two numbers" in {
10-
SubtractorScala.minus(2, 1) mustEqual 1
11-
}
4+
/** Created by Mikhail Kokho on 7/10/2015.
5+
*/
6+
class SubtractorTestSuite extends FunSuite {
7+
test("Subtractor should subtract two numbers") {
8+
assertEquals(SubtractorScala.minus(2, 1), 1)
129
}
1310
}
14-

‎src/sbt-test/scoverage/aggregate-only/test

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
> coverage
44
> test
55
# There should be scoverage-data directories for modules
6-
$ exists partA/target/scala-2.12/scoverage-data
7-
$ exists partB/target/scala-2.12/scoverage-data
6+
$ exists partA/target/scala-2.13/scoverage-data
7+
$ exists partB/target/scala-2.13/scoverage-data
88
# Generate aggregated reports without generating per-module reports first
99
> coverageAggregate
1010
# There shouldn't be scoverage-report directories for modules
11-
-$ exists partA/target/scala-2.12/scoverage-report
12-
-$ exists partB/target/scala-2.12/scoverage-report
11+
-$ exists partA/target/scala-2.13/scoverage-report
12+
-$ exists partB/target/scala-2.13/scoverage-report
1313
# There should be a root scoverage-report directory
14-
$ exists target/scala-2.12/scoverage-report
14+
$ exists target/scala-2.13/scoverage-report
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
/*
22
The projects test aggregation of coverage reports from two sub-projects.
33
The sub-projects are in the directories partA and partB.
4-
*/
4+
*/
55

66
lazy val commonSettings = Seq(
77
organization := "org.scoverage",
88
version := "0.1.0",
9-
scalaVersion := "2.12.13"
9+
scalaVersion := "2.13.5"
1010
)
1111

12-
lazy val specs2Lib = "org.specs2" %% "specs2" % "2.5" % "test"
13-
1412
def module(name: String) = {
1513
val id = s"part$name"
1614
Project(id = id, base = file(id))
1715
.settings(commonSettings: _*)
1816
.settings(
1917
Keys.name := name,
20-
libraryDependencies += specs2Lib
18+
libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
2119
)
2220
}
2321

2422
lazy val partA = module("A")
2523
lazy val partB = module("B")
2624

2725
lazy val root = (project in file("."))
28-
.settings(commonSettings:_*)
26+
.settings(commonSettings: _*)
2927
.settings(
3028
name := "root",
31-
test := { }
32-
).aggregate(
29+
test := {}
30+
)
31+
.aggregate(
3332
partA,
3433
partB
3534
)
3635

3736
ThisBuild / resolvers ++= {
38-
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots"))
37+
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT")))
38+
Seq(Resolver.sonatypeRepo("snapshots"))
3939
else Seq.empty
4040
}
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
import org.specs2.mutable._
1+
import munit.FunSuite
22
import org.scoverage.issue53.part.a.AdderScala
33

4-
/**
5-
* Created by Mikhail Kokho on 7/10/2015.
6-
*/
7-
class AdderTestSuite extends Specification {
8-
"Adder" should {
9-
"sum two numbers" in {
10-
AdderScala.add(1, 2) mustEqual 3
11-
}
4+
/** Created by Mikhail Kokho on 7/10/2015.
5+
*/
6+
class AdderTestSuite extends FunSuite {
7+
test("Adder should sum two numbers") {
8+
assertEquals(AdderScala.add(1, 2), 3)
129
}
1310
}
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
import org.specs2.mutable._
1+
import munit.FunSuite
22
import org.scoverage.issue53.part.b.SubtractorScala
33

4-
/**
5-
* Created by Mikhail Kokho on 7/10/2015.
6-
*/
7-
class SubtractorTestSuite extends Specification {
8-
"Subtractor" should {
9-
"subtract two numbers" in {
10-
SubtractorScala.minus(2, 1) mustEqual 1
11-
}
4+
/** Created by Mikhail Kokho on 7/10/2015.
5+
*/
6+
class SubtractorTestSuite extends FunSuite {
7+
test("Subtractor should substract two numbers") {
8+
assertEquals(SubtractorScala.minus(2, 1), 1)
129
}
1310
}
14-

‎src/sbt-test/scoverage/aggregate/test

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
> coverage
44
> test
55
# There should be scoverage-data directory
6-
$ exists partA/target/scala-2.12/scoverage-data
7-
$ exists partB/target/scala-2.12/scoverage-data
6+
$ exists partA/target/scala-2.13/scoverage-data
7+
$ exists partB/target/scala-2.13/scoverage-data
88
> coverageReport
99
# There should be scoverage-report directory
10-
$ exists partA/target/scala-2.12/scoverage-report
11-
$ exists partB/target/scala-2.12/scoverage-report
10+
$ exists partA/target/scala-2.13/scoverage-report
11+
$ exists partB/target/scala-2.13/scoverage-report
1212
> coverageAggregate
1313
# There should be a root scoverage-report directory
14-
$ exists target/scala-2.12/scoverage-report
14+
$ exists target/scala-2.13/scoverage-report
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
version := "0.1"
22

3-
scalaVersion := "2.12.13"
3+
scalaVersion := "2.13.5"
44

5-
libraryDependencies += "org.specs2" %% "specs2" % "2.5" % "test"
5+
libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
66

77
coverageMinimum := 80
88

99
coverageFailOnMinimum := true
1010

1111
resolvers ++= {
12-
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots"))
12+
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT")))
13+
Seq(Resolver.sonatypeRepo("snapshots"))
1314
else Seq.empty
1415
}
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
import org.specs2.mutable._
1+
import munit.FunSuite
22

3-
/**
4-
* Created by tbarke001c on 7/8/14.
5-
*/
6-
class BadCoverageSpec extends Specification {
3+
/** Created by tbarke001c on 7/8/14.
4+
*/
5+
class BadCoverageSpec extends FunSuite {
76

8-
"BadCoverage" should {
9-
"sum two numbers" in {
10-
BadCoverage.sum(1, 2) mustEqual 3
11-
}
7+
test("BadCoverage should sum two numbers") {
8+
assertEquals(BadCoverage.sum(1, 2), 3)
129
}
1310
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
version := "0.1"
22

3-
scalaVersion := "2.12.13"
3+
scalaVersion := "2.13.5"
44

5-
libraryDependencies += "org.specs2" %% "specs2" % "2.5" % "test"
5+
libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
66

77
coverageMinimum := 80
88

99
coverageFailOnMinimum := true
1010

1111
resolvers ++= {
12-
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots"))
12+
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT")))
13+
Seq(Resolver.sonatypeRepo("snapshots"))
1314
else Seq.empty
1415
}
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
import org.specs2.mutable._
1+
import munit.FunSuite
22

3-
/**
4-
* Created by tbarke001c on 7/8/14.
5-
*/
6-
class GoodCoverageSpec extends Specification {
3+
/** Created by tbarke001c on 7/8/14.
4+
*/
5+
class GoodCoverageSpec extends FunSuite {
76

8-
"GoodCoverage" should {
9-
"sum two numbers" in {
10-
GoodCoverage.sum(1, 2) mustEqual 3
11-
}
7+
test("GoodCoverage should sum two numvers") {
8+
assertEquals(GoodCoverage.sum(1, 2), 3)
129
}
1310
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
version := "0.1"
22

3-
scalaVersion := "2.12.13"
3+
scalaVersion := "2.13.5"
44

5-
libraryDependencies += "org.specs2" %% "specs2" % "2.5" % "test"
5+
libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
66

77
coverageMinimum := 80
88

99
coverageFailOnMinimum := true
1010

1111
resolvers ++= {
12-
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots"))
12+
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT")))
13+
Seq(Resolver.sonatypeRepo("snapshots"))
1314
else Seq.empty
1415
}
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
import org.specs2.mutable._
1+
import munit.FunSuite
22

3-
/**
4-
* Created by tbarke001c on 7/8/14.
5-
*/
6-
class GoodCoverageSpec extends Specification {
3+
/** Created by tbarke001c on 7/8/14.
4+
*/
5+
class GoodCoverageSpec extends FunSuite {
76

8-
"GoodCoverage" should {
9-
"sum two numbers" in {
10-
GoodCoverage.sum(1, 2) mustEqual 3
11-
}
7+
test("GoodCoverage should sum two numbers") {
8+
assertEquals(GoodCoverage.sum(1, 2), 3)
129
}
1310
}

‎src/sbt-test/scoverage/preserve-set/build.sbt

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,39 @@ import sbt.complete.DefaultParsers._
22

33
version := "0.1"
44

5-
scalaVersion := "2.12.13"
5+
scalaVersion := "2.13.5"
66

7-
crossScalaVersions := Seq("2.12.13")
7+
crossScalaVersions := Seq("2.13.5")
88

9-
libraryDependencies += "org.specs2" %% "specs2" % "2.5" % "test"
9+
libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
1010

11-
val checkScalaVersion = inputKey[Unit]("Input task to compare the value of scalaVersion setting with a given input.")
11+
val checkScalaVersion = inputKey[Unit](
12+
"Input task to compare the value of scalaVersion setting with a given input."
13+
)
1214
checkScalaVersion := {
1315
val arg: String = (Space ~> StringBasic).parsed
14-
if (scalaVersion.value != arg) sys.error(s"scalaVersion [${scalaVersion.value}] not equal to expected [$arg]")
16+
if (scalaVersion.value != arg)
17+
sys.error(
18+
s"scalaVersion [${scalaVersion.value}] not equal to expected [$arg]"
19+
)
1520
()
1621
}
1722

18-
val checkScoverageEnabled = inputKey[Unit]("Input task to compare the value of coverageEnabled setting with a given input.")
23+
val checkScoverageEnabled = inputKey[Unit](
24+
"Input task to compare the value of coverageEnabled setting with a given input."
25+
)
1926
checkScoverageEnabled := {
2027
val arg: String = (Space ~> StringBasic).parsed
21-
if (coverageEnabled.value.toString != arg) sys.error(s"coverageEnabled [${coverageEnabled.value}] not equal to expected [$arg]")
28+
if (coverageEnabled.value.toString != arg)
29+
sys.error(
30+
s"coverageEnabled [${coverageEnabled.value}] not equal to expected [$arg]"
31+
)
2232
()
2333
}
2434

25-
2635
resolvers ++= {
27-
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots"))
36+
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT")))
37+
Seq(Resolver.sonatypeRepo("snapshots"))
2838
else Seq.empty
2939
}
3040

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import org.specs2.mutable._
1+
import munit.FunSuite
22

3-
class PreserveSetSpec extends Specification {
3+
class PreserveSetSpec extends FunSuite {
44

5-
"PreserveSet" should {
6-
"sum two numbers" in {
7-
PreserveSet.sum(1, 2) mustEqual 3
8-
}
5+
test("PreserveSet should sum two numbers") {
6+
assertEquals(PreserveSet.sum(1, 2), 3)
97
}
108
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# check scalaVersion setting
2-
> checkScalaVersion "2.12.13"
2+
> checkScalaVersion "2.13.5"
33
> checkScoverageEnabled "false"
44
> coverage
55
> checkScoverageEnabled "true"
66
> coverageOff
7-
> checkScalaVersion "2.12.13"
8-
> checkScoverageEnabled "false"
7+
> checkScalaVersion "2.13.5"
8+
> checkScoverageEnabled "false"

‎src/sbt-test/scoverage/scalac-plugin-version/build.sbt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ lazy val root = (project in file(".")).settings(
55
TaskKey[Unit]("check") := {
66
assert(
77
libraryDependencies.value.count(module =>
8-
module.organization == "org.scoverage" && module.revision == "1.3.0") == 2)
8+
module.organization == "org.scoverage" && module.revision == "1.3.0"
9+
) == 2
10+
)
911
}
1012

1113
resolvers ++= {
12-
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots"))
14+
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT")))
15+
Seq(Resolver.sonatypeRepo("snapshots"))
1316
else Seq.empty
1417
}

‎src/sbt-test/scoverage/scalajs/build.sbt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ import sbtcrossproject.CrossType
33

44
lazy val root = (project in file(".")).aggregate(crossJS, crossJVM)
55

6-
lazy val cross = CrossProject("sjstest", file("sjstest"))(JVMPlatform, JSPlatform)
7-
.crossType(CrossType.Full)
8-
.settings(
9-
scalaVersion := "2.12.13",
10-
libraryDependencies ++= Seq(
11-
"org.scalatest" %% "scalatest" % "3.2.8" % "test"
6+
lazy val cross =
7+
CrossProject("sjstest", file("sjstest"))(JVMPlatform, JSPlatform)
8+
.crossType(CrossType.Full)
9+
.settings(
10+
scalaVersion := "2.13.5",
11+
libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
1212
)
13-
)
1413

1514
lazy val crossJS = cross.js
1615
lazy val crossJVM = cross.jvm
1716

1817
ThisBuild / resolvers ++= {
19-
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots"))
18+
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT")))
19+
Seq(Resolver.sonatypeRepo("snapshots"))
2020
else Seq.empty
2121
}
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import org.scalatest.flatspec.AnyFlatSpec
2-
import org.scalatest.matchers.should.Matchers
1+
import munit.FunSuite
32

4-
class JsTest extends AnyFlatSpec with Matchers {
3+
class JsTest extends FunSuite {
54

6-
"JS UnderTest" should "work on JS" in {
7-
UnderTest.jsMethod shouldBe "js"
5+
test("JS UnderTest should work on JS") {
6+
assertEquals(UnderTest.jsMethod, "js")
87
}
98

109
}
11-
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import org.scalatest.flatspec.AnyFlatSpec
2-
import org.scalatest.matchers.should.Matchers
1+
import munit.FunSuite
32

4-
class JvmTest extends AnyFlatSpec with Matchers {
3+
class JvmTest extends FunSuite {
54

6-
"JVM UnderTest" should "work on JVM" in {
7-
UnderTest.jvmMethod shouldBe "jvm"
5+
test("JVM UnderTest work on JVM") {
6+
assertEquals(UnderTest.jvmMethod, "jvm")
87
}
98

109
}
11-
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import org.scalatest.flatspec.AnyFlatSpec
2-
import org.scalatest.matchers.should.Matchers
1+
import munit.FunSuite
32

4-
class SharedTest extends AnyFlatSpec with Matchers {
3+
class SharedTest extends FunSuite {
54

6-
"Shared UnderTest" should "return where it works" in {
7-
UnderTest.onJsAndJvm shouldBe "js and jvm"
5+
test("Shared UnderTest return where it works") {
6+
assertEquals(UnderTest.onJsAndJvm, "js and jvm")
87
}
98

109
}

‎src/sbt-test/scoverage/scalajs/test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
> coverage
44
> test
55
# There should be scoverage-data directory
6-
$ exists sjstest/js/target/scala-2.12/scoverage-data
7-
$ exists sjstest/jvm/target/scala-2.12/scoverage-data
6+
$ exists sjstest/js/target/scala-2.13/scoverage-data
7+
$ exists sjstest/jvm/target/scala-2.13/scoverage-data
88
> coverageReport
99
# There should be scoverage-report directory
10-
$ exists sjstest/js/target/scala-2.12/scoverage-report
11-
$ exists sjstest/jvm/target/scala-2.12/scoverage-report
10+
$ exists sjstest/js/target/scala-2.13/scoverage-report
11+
$ exists sjstest/jvm/target/scala-2.13/scoverage-report

0 commit comments

Comments
 (0)
Please sign in to comment.