File tree 12 files changed +137
-8
lines changed
12 files changed +137
-8
lines changed Original file line number Diff line number Diff line change @@ -155,15 +155,9 @@ object ScoverageSbtPlugin extends AutoPlugin {
155
155
// rangepos is broken in some releases of scala so option to turn it off
156
156
if (coverageHighlighting.value) Some (" -Yrangepos" ) else None
157
157
).flatten
158
- } else if (
159
- // TODO this is very temporary until support for this gets merged in.
160
- // For now we restrict this to this exact SNAPSHOT version which needs
161
- // to be published localled in order to test
162
- coverageEnabled.value && scalaVersion.value == " 3.1.2-RC1-bin-SNAPSHOT"
163
- ) {
158
+ } else if (coverageEnabled.value) {
164
159
Seq (
165
- " -coverage" ,
166
- s " ${coverageDataDir.value.getAbsolutePath()}/scoverage-data "
160
+ s " -coverage-out: ${coverageDataDir.value.getAbsolutePath()}/scoverage-data "
167
161
)
168
162
} else {
169
163
Nil
Original file line number Diff line number Diff line change
1
+ version := " 0.1"
2
+
3
+ scalaVersion := " 3.2.0-RC1-bin-20220523-6783853-NIGHTLY" // TODO: Should be updated to stable version on 3.2.0-RC1 release
4
+
5
+ libraryDependencies += " org.scalameta" %% " munit" % " 0.7.29" % Test
6
+
7
+ coverageMinimum := 80
8
+
9
+ coverageFailOnMinimum := true
10
+
11
+ coverageEnabled := true
12
+
13
+ resolvers ++= {
14
+ if (sys.props.get(" plugin.version" ).exists(_.endsWith(" -SNAPSHOT" )))
15
+ Seq (Resolver .sonatypeRepo(" snapshots" ))
16
+ else Seq .empty
17
+ }
Original file line number Diff line number Diff line change
1
+ val pluginVersion = sys.props.getOrElse(
2
+ " plugin.version" ,
3
+ throw new RuntimeException (
4
+ """ |The system property 'plugin.version' is not defined.
5
+ |Specify this property using the scriptedLaunchOpts -D.""" .stripMargin
6
+ )
7
+ )
8
+
9
+ addSbtPlugin(" org.scoverage" % " sbt-scoverage" % pluginVersion)
10
+
11
+ resolvers ++= {
12
+ if (pluginVersion.endsWith(" -SNAPSHOT" ))
13
+ Seq (Resolver .sonatypeRepo(" snapshots" ))
14
+ else
15
+ Seq .empty
16
+ }
Original file line number Diff line number Diff line change
1
+ object BadCoverage {
2
+
3
+ def sum (num1 : Int , num2 : Int ) = {
4
+ num1 + num2
5
+ }
6
+
7
+ def mult (num1 : Int , num2 : Int ) = {
8
+ num1 * num2
9
+ }
10
+ }
Original file line number Diff line number Diff line change
1
+ import munit .FunSuite
2
+
3
+ /** Created by tbarke001c on 7/8/14.
4
+ */
5
+ class BadCoverageSpec extends FunSuite {
6
+
7
+ test(" BadCoverage should sum two numbers" ) {
8
+ assertEquals(BadCoverage .sum(1 , 2 ), 3 )
9
+ }
10
+ }
Original file line number Diff line number Diff line change
1
+ # run scoverage
2
+ > clean
3
+ > coverage
4
+ > test
5
+ -> coverageReport
Original file line number Diff line number Diff line change
1
+ version := " 0.1"
2
+
3
+ scalaVersion := " 3.2.0-RC1-bin-20220523-6783853-NIGHTLY" // TODO: Should be updated to stable version on 3.2.0-RC1 release
4
+
5
+ libraryDependencies += " org.scalameta" %% " munit" % " 0.7.29" % Test
6
+
7
+ coverageMinimum := 80
8
+ coverageMinimumStmtTotal := 100
9
+ coverageMinimumBranchTotal := 100
10
+ coverageMinimumStmtPerPackage := 100
11
+ coverageMinimumBranchPerPackage := 100
12
+ coverageMinimumStmtPerFile := 100
13
+ coverageMinimumBranchPerFile := 100
14
+
15
+ coverageFailOnMinimum := true
16
+
17
+ resolvers ++= {
18
+ if (sys.props.get(" plugin.version" ).exists(_.endsWith(" -SNAPSHOT" )))
19
+ Seq (Resolver .sonatypeRepo(" snapshots" ))
20
+ else Seq .empty
21
+ }
Original file line number Diff line number Diff line change
1
+ val pluginVersion = sys.props.getOrElse(
2
+ " plugin.version" ,
3
+ throw new RuntimeException (
4
+ """ |The system property 'plugin.version' is not defined.
5
+ |Specify this property using the scriptedLaunchOpts -D.""" .stripMargin
6
+ )
7
+ )
8
+
9
+ addSbtPlugin(" org.scoverage" % " sbt-scoverage" % pluginVersion)
10
+
11
+ resolvers ++= {
12
+ if (pluginVersion.endsWith(" -SNAPSHOT" ))
13
+ Seq (Resolver .sonatypeRepo(" snapshots" ))
14
+ else
15
+ Seq .empty
16
+ }
Original file line number Diff line number Diff line change
1
+ object GoodCoverage {
2
+
3
+ def sum (num1 : Int , num2 : Int ) = {
4
+ if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2
5
+ }
6
+
7
+ }
Original file line number Diff line number Diff line change
1
+ package two
2
+
3
+ object GoodCoverage {
4
+
5
+ def sum (num1 : Int , num2 : Int ) = {
6
+ if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2
7
+ }
8
+
9
+ }
Original file line number Diff line number Diff line change
1
+ import munit .FunSuite
2
+
3
+ /** Created by tbarke001c on 7/8/14.
4
+ */
5
+ class GoodCoverageSpec extends FunSuite {
6
+
7
+ test(" GoodCoverage should sum two numbers" ) {
8
+ assertEquals(GoodCoverage .sum(1 , 2 ), 3 )
9
+ assertEquals(GoodCoverage .sum(0 , 3 ), 3 )
10
+ assertEquals(GoodCoverage .sum(3 , 0 ), 3 )
11
+ }
12
+
13
+ test(" two.GoodCoverage should sum two numbers" ) {
14
+ assertEquals(two.GoodCoverage .sum(1 , 2 ), 3 )
15
+ assertEquals(two.GoodCoverage .sum(0 , 3 ), 3 )
16
+ assertEquals(two.GoodCoverage .sum(3 , 0 ), 3 )
17
+ }
18
+
19
+ }
Original file line number Diff line number Diff line change
1
+ # run scoverage
2
+ > clean
3
+ > coverage
4
+ > test
5
+ > coverageReport
You can’t perform that action at this time.
0 commit comments