diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
new file mode 100644
index 00000000..cbc018a2
--- /dev/null
+++ b/.git-blame-ignore-revs
@@ -0,0 +1,6 @@
+# It's a good idea to ignore the following commits from git blame.j
+# You can read more about this here if you're unfamiliar:
+# https://www.moxio.com/blog/43/ignoring-bulk-change-commits-with-git-blame
+#
+# Added scalafmt
+af2396558918fea00eaa2da12906a3012eb72153
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 00000000..e33811f6
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,7 @@
+version: 2
+updates:
+
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "monthly"
diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml
new file mode 100644
index 00000000..27bcee3f
--- /dev/null
+++ b/.github/release-drafter.yml
@@ -0,0 +1,4 @@
+template: |
+ ## What’s Changed
+
+ $CHANGES
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 00000000..7ccae35e
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,49 @@
+name: CI
+
+on:
+ push:
+ paths-ignore:
+ - '*.md'
+ branches:
+ - main
+ pull_request:
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ java: [ '8', '11' ]
+
+ steps:
+ - name: checkout the repo
+ uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+
+ - name: Set up JVM
+ uses: actions/setup-java@v2
+ with:
+ distribution: 'adopt'
+ java-version: ${{ matrix.java }}
+
+ - name: Run tests
+ run: sbt scripted
+
+ formatting:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: checkout the repo
+ uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+
+ - name: Set up JVM
+ uses: actions/setup-java@v2
+ with:
+ distribution: 'adopt'
+ java-version: '8'
+
+ - name: Check Formatting
+ run: sbt scalafmtCheckAll
diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml
new file mode 100644
index 00000000..896edaf4
--- /dev/null
+++ b/.github/workflows/release-drafter.yml
@@ -0,0 +1,14 @@
+name: Release Drafter
+
+on:
+ push:
+ branches:
+ - main
+
+jobs:
+ update_release_draft:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: release-drafter/release-drafter@v5
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 00000000..3370fc55
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,23 @@
+name: Release
+on:
+ push:
+ branches:
+ - main
+ tags: ["*"]
+jobs:
+ publish:
+ runs-on: ubuntu-20.04
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+ - uses: actions/setup-java@v2
+ with:
+ distribution: 'adopt'
+ java-version: '11'
+ - run: sbt ci-release
+ env:
+ PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
+ PGP_SECRET: ${{ secrets.PGP_SECRET }}
+ SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
+ SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
diff --git a/.scala-steward.conf b/.scala-steward.conf
new file mode 100644
index 00000000..1a44ff58
--- /dev/null
+++ b/.scala-steward.conf
@@ -0,0 +1 @@
+updates.ignore = [ { groupId = "org.scala-lang" } ]
diff --git a/.scalafmt.conf b/.scalafmt.conf
new file mode 100644
index 00000000..ddb90c2d
--- /dev/null
+++ b/.scalafmt.conf
@@ -0,0 +1 @@
+version = "3.0.2"
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index f9cd7f16..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-language: scala
-
-script: sbt ^^$TRAVIS_SBT_VERSION scripted
-
-matrix:
- include:
- - env: TRAVIS_SBT_VERSION="0.13.18"
- - env: TRAVIS_SBT_VERSION="1.2.8"
-
-before_cache:
- - find $HOME/.sbt -name "*.lock" | xargs rm
- - find $HOME/.ivy2 -name "ivydata-*.properties" | xargs rm
-
-cache:
- directories:
- - $HOME/.ivy2/cache
- - $HOME/.sbt/boot
-
-before_script:
- - sudo chmod +x /usr/local/bin/sbt
diff --git a/README.md b/README.md
index 94454d41..f1ae2d31 100644
--- a/README.md
+++ b/README.md
@@ -1,32 +1,24 @@
-sbt-scoverage
-========
+# sbt-scoverage
-sbt-scoverage is a plugin for SBT that integrates the scoverage code coverage library. Find out more about [scoverage](https://github.com/scoverage/scalac-scoverage-plugin).
-
-Join the [scoverage](http://groups.google.com/group/scala-code-coverage-tool)
-google group for help, bug reports, feature requests, and general
-discussion on scoverage.
-
-[![Build Status](https://travis-ci.org/scoverage/sbt-scoverage.png?branch=master)](https://travis-ci.org/scoverage/sbt-scoverage)
+[![Gitter](https://img.shields.io/gitter/room/scoverage/scoverage.svg)](https://gitter.im/scoverage/scoverage)
+[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.scoverage/sbt-scoverage/badge.svg?kill_cache=1)](https://search.maven.org/artifact/org.scoverage/sbt-scoverage/)
[![License](http://img.shields.io/:license-Apache%202-red.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt)
-[](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22sbt-scoverage%22)
-## How to use
+sbt-scoverage is a plugin for sbt that integrates the scoverage code coverage
+library. Find out more about
+[scoverage here](https://github.com/scoverage/scalac-scoverage-plugin).
-Make sure your SBT version in project/build.properties:
-```
-sbt.version = 0.13.17
-```
-or
-```
-sbt.version = 1.1.1
-```
+## Setup
+
+**Requirements**: Requires sbt 1.2.8 or above
-Add the plugin in project/plugins.sbt:
+In `project/plugins.sbt`:
```scala
-addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
+addSbtPlugin("org.scoverage" % "sbt-scoverage" % "x.x.x")
```
+## Usage
+
Run the tests with enabled coverage:
```
$ sbt clean coverage test
@@ -37,7 +29,7 @@ $ sbt clean coverage it:test
```
To enable coverage directly in your build, use:
-```
+```scala
coverageEnabled := true
```
@@ -46,54 +38,40 @@ To generate the coverage reports run
$ sbt coverageReport
```
-Coverage reports will be in `target/scoverage-report`. There are HTML and XML reports. The XML is useful if you need to programatically use the results, or if you're writing a tool.
-
-If you're running the coverage reports from within an sbt console session (as
-opposed to one command per sbt launch), then the `coverage` command is sticky. To
-turn it back off when you're done running reports, use the `coverageOff` command or reset `coverageEnabled` with `set coverageEnabled := false`.
-
-Sample project with scoverage in both sbt and maven - [the scoverage samples project](https://github.com/scoverage/sbt-scoverage-samples).
-
-## Notes on upgrading to version 1.6.0
-
-* `coverageAggregate` aggregates raw coverage data, not coverage xml reports for modules.
-There is no requirement to generate individual coverage reports for modules (`coverageReport`)
-before generating aggregated report (`coverageAggregate`).
-
-If only aggregated report is required, not executing `coverageReport` can reduce the build time significantly.
-
-## Notes on upgrading to version 1.3.0
-
-* The object containing the keys has changed from nested to top level so you might need to adjust the import. It's also an auto plugin now, so you might not need the import at all.
-* There is an issue syncing the binary with the sbt-plugin-releases repo, so in the meantime add `resolvers += Resolver.url("scoverage-bintray", url("https://dl.bintray.com/sksamuel/sbt-plugins/"))(Resolver.ivyStylePatterns)` to your build.
+Coverage reports will be in your `target/scala-/scoverage-report`
+directory. There are HTML and XML reports. The XML is useful if you need to
+programatically use the results, or if you're writing a tool.
-## Notes on upgrading to version 1.0.0
+**NOTE**: If you're running the coverage reports from within an sbt console
+session (as opposed to one command per sbt launch), then the `coverage` command
+is sticky. To turn it back off when you're done running reports, use the
+`coverageOff` command or reset `coverageEnabled` with `set coverageEnabled :=
+false`.
-If you are upgrading from 0.99.x then you must remove the `instrumentSettings` from your build.sbt or Build.scala, as that is no longer needed.
+### Multi project reports
-Next, the keys have been renamed slightly. The new names begin with coverageXXX, eg coverageExcludedPackages and some have had their full name changed. You can see a full list of keys by opening the object ScoverageKeys.
+By default, scoverage will generate reports for each project separately. You can
+merge them into an aggregated report by using the following:
-## Multi project reports
-
-By default, scoverage will generate reports for each project separately. You can merge them into an aggregated report by invoking `sbt coverageAggregate`.
-
-(Note, you must do this after all the coverage data is complete as a separate command, so you cannot do `sbt coverage test coverageAggregate` (at least until a way around this is found).)
+```
+$ sbt coverageAggregate
+```
-(You must have first run `sbt coverageReport` for `coverageAggregate` to work. It aggregates over the sub-projects' report xml rather than over the coverage data directly.)
+**NOTE**: You do not need to run `coverageReport` before `coverageAggregate`; it
+aggregates over the sub-projects' coverage data directly, not the report xml.
-## Exclude classes and packages
+### Exclude classes and packages
-You can exclude classes from being considered for coverage measurement by providing semicolon-separated list of
-regular expressions.
+You can exclude classes from being considered for coverage measurement by
+providing semicolon-separated list of regular expressions.
-Example:
```scala
coverageExcludedPackages := ";Reverse.*;.*AuthService.*;models\\.data\\..*"
```
-The regular expressions are matched against the fully qualified class name, and must match the entire string to take effect.
-
-Any matched classes will not be instrumented or included in the coverage report.
+The regular expressions are matched against the fully qualified class name, and
+must match the entire string to take effect. Any matched classes will not be
+instrumented or included in the coverage report.
You can also mark sections of code with comments like:
@@ -103,67 +81,87 @@ You can also mark sections of code with comments like:
// $COVERAGE-ON$
```
-Any code between two such comments will not be instrumented or included in the coverage report.
+Any code between two such comments will not be instrumented or included in the
+coverage report.
-## Minimum coverage
+### Minimum coverage
-Based on minimum coverage, you can fail the build with the following keys
+Based on minimum coverage, you can fail the build with the following keys:
```scala
-coverageMinimum := 80
coverageFailOnMinimum := true
+coverageMinimumStmtTotal := 90
+coverageMinimumBranchTotal := 90
+coverageMinimumStmtPerPackage := 90
+coverageMinimumBranchPerPackage := 85
+coverageMinimumStmtPerFile := 85
+coverageMinimumBranchPerFile := 80
```
-These settings will be enforced when the reports are generated.
-If you generate an aggregate report using `coverageAggregate` then these settings will apply to that report.
+These settings will be enforced when the reports are generated. If you generate
+an aggregate report using `coverageAggregate` then these settings will apply to
+that report.
-## Highlighting
+### Override Location for Coverage Data And Report
-If you are using Scala 2.11.1 or less, then highlighting will not work (due to this bug which was fixed in 2.11.2 https://github.com/scala/scala/pull/3799). In that case you must disable highlighting by adding the following to your build:
+If desired, one could override the default location for generating the sbt report and data through setting `coverageDataDir`:
+Example in data-dir test:
```scala
-coverageHighlighting := false
+coverageDataDir := target.value / "custom-test"
```
-## Failing tests
-Scoverage does a lot of file writing behind the scenes in order to track which statements have been executed.
-If you are running into a scenario where your tests normally pass, but fail when scoverage is enabled, then the culprit can be one of the following:
+Can also be set through the sbt set directive
+```scala
+set coverageDataDir := file("/tmp")
+```
+
+
+## Trouble-shooting failing tests
+
+scoverage does a lot of file writing behind the scenes in order to track which
+statements have been executed. If you are running into a scenario where your
+tests normally pass, but fail when scoverage is enabled, then the culprit can be
+one of the following:
* timing issues on futures and other async operations, try upping the timeouts by an order of magnitude.
* tests are run in a sandbox mode (such as with `java.security.PrivilegedAction`), try running the tests outside of the sandbox.
+## Example project
+
+[the scoverage samples project](https://github.com/scoverage/sbt-scoverage-samples).
+
## Integrations
### Codacy
-[Codacy](https://www.codacy.com) integrates with your favorite coverage tool to provide an in-depth overlook of your project status. Scoverage information can be integrated into Codacy through the [sbt-codacy-coverage plugin](https://github.com/codacy/sbt-codacy-coverage).
+[Codacy](https://www.codacy.com) integrates with your favorite coverage tool to
+provide an in-depth overlook of your project status. scoverage information can
+be integrated into Codacy through the
+[codacy-coverage-reporter](https://github.com/codacy/codacy-coverage-reporter).
### Coveralls
-If you have an open source project then you can add code coverage metrics with the excellent website https://coveralls.io/ Scoverage will integrate with coveralls using the [sbt-coveralls](https://github.com/scoverage/sbt-coveralls) plugin.
-
-### Plugin for SonarQube
+If you have an open source project then you can add code coverage metrics with
+the [Coveralls](https://coveralls.io/). scoverage will integrate with coveralls
+using the [sbt-coveralls](https://github.com/scoverage/sbt-coveralls) plugin.
-If you want to visually browse statement coverage reports then use this [plugin for SonarQube](https://github.com/RadoBuransky/sonar-scoverage-plugin).
-It allows you to review overall project statement coverage as well as dig deeper into sub-modules, directories and
-source code files to see uncovered statements. Statement coverage measurement can become an integral part of your
-team's continuous integration process and a required quality standard.
+### Codecov
-## License
-```
-This software is licensed under the Apache 2 license, quoted below.
+You can integrate with [Codecov](https://about.codecov.io/) easily sending your
+reports there via your CI. You can see an example of this here in
+[codecov/example-scala](https://github.com/codecov/example-scala).
-Copyright 2013-2016 Stephen Samuel and contributors
+### Plugin for SonarQube
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
+If you want to visually browse statement coverage reports then use this [plugin
+for SonarQube](https://github.com/RadoBuransky/sonar-scoverage-plugin). It
+allows you to review overall project statement coverage as well as dig deeper
+into sub-modules, directories and source code files to see uncovered statements.
+Statement coverage measurement can become an integral part of your team's
+continuous integration process and a required quality standard.
- http://www.apache.org/licenses/LICENSE-2.0
+## Release Notes
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
-```
+For any information on releases and upgrading, please refer to the [release
+page](https://github.com/scoverage/sbt-scoverage/releases).
diff --git a/build.sbt b/build.sbt
index 47923c9f..c6f6b9bf 100644
--- a/build.sbt
+++ b/build.sbt
@@ -1,77 +1,58 @@
name := "sbt-scoverage"
-organization := "org.scoverage"
-
-enablePlugins(SbtPlugin)
-
-scalacOptions := Seq("-unchecked", "-deprecation", "-feature", "-encoding", "utf8")
-
-resolvers ++= {
- if (isSnapshot.value) Seq(Resolver.sonatypeRepo("snapshots")) else Nil
-}
-
-libraryDependencies += "org.scoverage" %% "scalac-scoverage-plugin" % "1.4.0"
-
-publishMavenStyle := true
-
-publishArtifact in Test := false
-
-scriptedLaunchOpts ++= Seq(
- "-Xmx1024M",
- "-Dplugin.version=" + version.value
+import sbt.ScriptedPlugin.autoImport.scriptedLaunchOpts
+
+def scoverageVersion = "1.4.8"
+def version := "1.9.0-livongo-1.0.2"
+
+inThisBuild(
+ List(
+ organization := "org.scoverage",
+ homepage := Some(url("http://scoverage.org/")),
+ developers := List(
+ Developer(
+ "sksamuel",
+ "Stephen Samuel",
+ "sam@sksamuel.com",
+ url("https://github.com/sksamuel")
+ ),
+ Developer(
+ "gslowikowski",
+ "Grzegorz Slowikowski",
+ "gslowikowski@gmail.com",
+ url("https://github.com/gslowikowski")
+ )
+ ),
+ licenses := Seq(
+ "Apache-2.0" -> url("http://www.apache.org/license/LICENSE-2.0")
+ ),
+ scalaVersion := "2.12.14"
+ )
)
-import ReleaseTransformations._
-releaseProcess := Seq[ReleaseStep](
- checkSnapshotDependencies,
- inquireVersions,
- runClean,
- releaseStepCommandAndRemaining("^ test"),
- setReleaseVersion,
- commitReleaseVersion,
- tagRelease,
- releaseStepCommandAndRemaining("^ publishSigned"),
- setNextVersion,
- commitNextVersion,
- pushChanges
-)
-
-releaseCrossBuild := false
-
-publishTo := {
- if (isSnapshot.value)
- Some("snapshots" at "https://oss.sonatype.org/content/repositories/snapshots")
- else
- Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2")
-}
-
-pomExtra := {
- https://github.com/scoverage/sbt-scoverage
-
-
- Apache 2
- http://www.apache.org/licenses/LICENSE-2.0
- repo
-
-
-
- git@github.com:scoverage/sbt-scoverage.git
- scm:git@github.com:scoverage/sbt-scoverage.git
-
-
-
- sksamuel
- sksamuel
- http://github.com/sksamuel
-
-
- gslowikowski
- Grzegorz Slowikowski
- http://github.com/gslowikowski
-
-
-}
-
-crossSbtVersions := Vector("0.13.18", "1.2.8")
-
-scalariformAutoformat := false
+lazy val root = Project("sbt-scoverage", file("."))
+ .enablePlugins(SbtPlugin, BuildInfoPlugin)
+ .settings(
+ libraryDependencies ++= Seq(
+ "org.scoverage" %% "scalac-scoverage-plugin" % scoverageVersion cross (CrossVersion.full)
+ ),
+ buildInfoKeys := Seq[BuildInfoKey]("scoverageVersion" -> scoverageVersion),
+ buildInfoPackage := "scoverage",
+ Test / fork := false,
+ Test / publishArtifact := false,
+ Test / parallelExecution := false,
+ scalacOptions := Seq(
+ "-unchecked",
+ "-deprecation",
+ "-feature",
+ "-encoding",
+ "utf8"
+ ),
+ resolvers ++= {
+ if (isSnapshot.value) Seq(Resolver.sonatypeRepo("snapshots")) else Nil
+ },
+ scriptedLaunchOpts ++= Seq(
+ "-Xmx1024M",
+ "-Dplugin.version=" + version.value
+ )
+ )
diff --git a/project/build.properties b/project/build.properties
index c0bab049..10fd9eee 100644
--- a/project/build.properties
+++ b/project/build.properties
@@ -1 +1 @@
-sbt.version=1.2.8
+sbt.version=1.5.5
diff --git a/project/plugins.sbt b/project/plugins.sbt
index 8652f6d6..559fb208 100644
--- a/project/plugins.sbt
+++ b/project/plugins.sbt
@@ -1,7 +1,4 @@
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value
-
-addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0")
-
-addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.1")
-
-addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.7")
+addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7")
+addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
+addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.3")
diff --git a/src/main/scala/scoverage/CoverageMinimum.scala b/src/main/scala/scoverage/CoverageMinimum.scala
new file mode 100644
index 00000000..8e0c3030
--- /dev/null
+++ b/src/main/scala/scoverage/CoverageMinimum.scala
@@ -0,0 +1,105 @@
+package scoverage
+
+import sbt._
+import scoverage.DoubleFormat.twoFractionDigits
+
+case class CoverageMinimum(
+ statement: Double,
+ branch: Double
+) {
+ def checkCoverage(
+ metrics: CoverageMetrics,
+ metric: String
+ )(implicit log: Logger): Boolean = {
+ CoverageMinimum.checkCoverage(
+ s"Branch:$metric",
+ branch,
+ metrics.branchCoveragePercent
+ ) &&
+ CoverageMinimum.checkCoverage(
+ s"Stmt:$metric",
+ statement,
+ metrics.statementCoveragePercent
+ )
+ }
+
+}
+
+object CoverageMinimum {
+
+ def checkCoverage(
+ metric: String,
+ min: Double,
+ cper: Double
+ )(implicit log: Logger): Boolean = {
+ // check for default minimum
+ min <= 0 || {
+ def is100(d: Double) = Math.abs(100 - d) <= 0.00001
+
+ if (is100(min) && is100(cper)) {
+ log.debug(s"100% Coverage: $metric")
+ true
+ } else {
+ val ok: Boolean = min <= cper
+ def minfmt = twoFractionDigits(min)
+ def cfmt = twoFractionDigits(cper)
+ if (ok) {
+ log.debug(s"Coverage is above minimum [$cfmt% >= $minfmt%]: $metric")
+ } else {
+ log.error(s"Coverage is below minimum [$cfmt% < $minfmt%]: $metric")
+ }
+ ok
+ }
+ }
+ }
+
+ case class All(
+ total: CoverageMinimum,
+ perPackage: CoverageMinimum,
+ perFile: CoverageMinimum
+ ) {
+ def checkCoverage(
+ coverage: Coverage,
+ failOnMin: Boolean
+ )(implicit log: Logger): Unit = {
+ val ok: Boolean = total.checkCoverage(coverage, "Total") &&
+ coverage.packages.forall(pkg =>
+ perPackage.checkCoverage(pkg, s"Package:${pkg.name}")
+ ) &&
+ coverage.files.forall(file =>
+ perFile.checkCoverage(file, s"File:${file.filename}")
+ )
+
+ if (!ok && failOnMin)
+ throw new RuntimeException("Coverage minimum was not reached")
+
+ log.info(
+ s"All done. Coverage was" +
+ s" stmt=[${coverage.statementCoverageFormatted}%]" +
+ s" branch=[${coverage.branchCoverageFormatted}%]"
+ )
+ }
+
+ }
+
+ def all = Def.setting {
+ import ScoverageKeys._
+ val stmtTotal =
+ math.max(coverageMinimum.value, coverageMinimumStmtTotal.value)
+ All(
+ total = CoverageMinimum(
+ statement = stmtTotal,
+ branch = coverageMinimumBranchTotal.value
+ ),
+ perPackage = CoverageMinimum(
+ statement = coverageMinimumStmtPerPackage.value,
+ branch = coverageMinimumBranchPerPackage.value
+ ),
+ perFile = CoverageMinimum(
+ statement = coverageMinimumStmtPerFile.value,
+ branch = coverageMinimumBranchPerFile.value
+ )
+ )
+ }
+
+}
diff --git a/src/main/scala/scoverage/ScoverageKeys.scala b/src/main/scala/scoverage/ScoverageKeys.scala
index b3eec0dc..add12d0c 100644
--- a/src/main/scala/scoverage/ScoverageKeys.scala
+++ b/src/main/scala/scoverage/ScoverageKeys.scala
@@ -3,20 +3,39 @@ package scoverage
import sbt._
object ScoverageKeys {
- lazy val coverageEnabled = settingKey[Boolean]("controls whether code instrumentation is enabled or not")
+ // format: off
+ lazy val coverageEnabled = settingKey[Boolean](
+ "controls whether code instrumentation is enabled or not"
+ )
lazy val coverageReport = taskKey[Unit]("run report generation")
lazy val coverageAggregate = taskKey[Unit]("aggregate reports from subprojects")
lazy val coverageExcludedPackages = settingKey[String]("regex for excluded packages")
lazy val coverageExcludedFiles = settingKey[String]("regex for excluded file paths")
- lazy val coverageMinimum = settingKey[Double]("scoverage-minimum-coverage")
- lazy val coverageFailOnMinimum = settingKey[Boolean]("if coverage is less than this value then fail build")
lazy val coverageHighlighting = settingKey[Boolean]("enables range positioning for highlighting")
lazy val coverageOutputCobertura = settingKey[Boolean]("enables cobertura XML report generation")
lazy val coverageOutputXML = settingKey[Boolean]("enables xml report generation")
lazy val coverageOutputHTML = settingKey[Boolean]("enables html report generation")
lazy val coverageOutputDebug = settingKey[Boolean]("turn on the debug report")
- @deprecated("", "1.6.0")
- lazy val coverageCleanSubprojectFiles = settingKey[Boolean]("removes subproject data after an aggregation")
lazy val coverageOutputTeamCity = settingKey[Boolean]("turn on teamcity reporting")
lazy val coverageScalacPluginVersion = settingKey[String]("version of scalac-scoverage-plugin to use")
+ lazy val coverageDataDir = settingKey[File]("directory where the measurements and report files will be stored")
+ // format: on
+
+ @deprecated("Use coverageMinimumStmtTotal instead", "v1.8.0")
+ lazy val coverageMinimum =
+ settingKey[Double]("see coverageMinimumStmtTotal")
+ lazy val coverageMinimumStmtTotal =
+ settingKey[Double]("scoverage minimum coverage: statement total")
+ lazy val coverageMinimumBranchTotal =
+ settingKey[Double]("scoverage minimum coverage: branch total")
+ lazy val coverageMinimumStmtPerPackage =
+ settingKey[Double]("scoverage minimum coverage: statement per package")
+ lazy val coverageMinimumBranchPerPackage =
+ settingKey[Double]("scoverage minimum coverage: branch per package")
+ lazy val coverageMinimumStmtPerFile =
+ settingKey[Double]("scoverage minimum coverage: statement per file")
+ lazy val coverageMinimumBranchPerFile =
+ settingKey[Double]("scoverage minimum coverage: branch per file")
+ lazy val coverageFailOnMinimum =
+ settingKey[Boolean]("if coverage is less than minimum then fail build")
}
diff --git a/src/main/scala/scoverage/ScoverageSbtPlugin.scala b/src/main/scala/scoverage/ScoverageSbtPlugin.scala
index 04b4d41f..1e243a75 100644
--- a/src/main/scala/scoverage/ScoverageSbtPlugin.scala
+++ b/src/main/scala/scoverage/ScoverageSbtPlugin.scala
@@ -3,83 +3,112 @@ package scoverage
import sbt.Keys._
import sbt._
import sbt.plugins.JvmPlugin
-import scoverage.report.{CoberturaXmlWriter, CoverageAggregator, ScoverageHtmlWriter, ScoverageXmlWriter}
+import scoverage.report.CoberturaXmlWriter
+import scoverage.report.CoverageAggregator
+import scoverage.report.ScoverageHtmlWriter
+import scoverage.report.ScoverageXmlWriter
+
+import java.time.Instant
object ScoverageSbtPlugin extends AutoPlugin {
- val OrgScoverage = "org.scoverage"
- val ScalacRuntimeArtifact = "scalac-scoverage-runtime"
- val ScalacPluginArtifact = "scalac-scoverage-plugin"
- // this should match the version defined in build.sbt
- val DefaultScoverageVersion = "1.4.1"
+ val orgScoverage = "org.scoverage"
+ val scalacRuntimeArtifact = "scalac-scoverage-runtime"
+ val scalacPluginArtifact = "scalac-scoverage-plugin"
+ val defaultScoverageVersion = BuildInfo.scoverageVersion
val autoImport = ScoverageKeys
lazy val ScoveragePluginConfig = config("scoveragePlugin").hide
import autoImport._
- val aggregateFilter = ScopeFilter(inAggregates(ThisProject),
- inConfigurations(Compile)) // must be outside of the 'coverageAggregate' task (see: https://github.com/sbt/sbt/issues/1095 or https://github.com/sbt/sbt/issues/780)
+ val aggregateFilter = ScopeFilter(
+ inAggregates(ThisProject),
+ inConfigurations(Compile)
+ ) // must be outside of the 'coverageAggregate' task (see: https://github.com/sbt/sbt/issues/1095 or https://github.com/sbt/sbt/issues/780)
override def requires: JvmPlugin.type = plugins.JvmPlugin
override def trigger: PluginTrigger = allRequirements
- override def globalSettings: Seq[Def.Setting[_]] = super.globalSettings ++ Seq(
- coverageEnabled := false,
- coverageExcludedPackages := "",
- coverageExcludedFiles := "",
- coverageMinimum := 0, // default is no minimum
- coverageFailOnMinimum := false,
- coverageHighlighting := true,
- coverageOutputXML := true,
- coverageOutputHTML := true,
- coverageOutputCobertura := true,
- coverageOutputDebug := false,
- coverageCleanSubprojectFiles := true,
- coverageOutputTeamCity := false,
- coverageScalacPluginVersion := DefaultScoverageVersion
- )
+ override def globalSettings: Seq[Def.Setting[_]] =
+ super.globalSettings ++ Seq(
+ coverageEnabled := false,
+ coverageExcludedPackages := "",
+ coverageExcludedFiles := "",
+ coverageMinimum := 0, // default is no minimum
+ coverageMinimumStmtTotal := 0,
+ coverageMinimumBranchTotal := 0,
+ coverageMinimumStmtPerPackage := 0,
+ coverageMinimumBranchPerPackage := 0,
+ coverageMinimumStmtPerFile := 0,
+ coverageMinimumBranchPerFile := 0,
+ coverageFailOnMinimum := false,
+ coverageHighlighting := true,
+ coverageOutputXML := true,
+ coverageOutputHTML := true,
+ coverageOutputCobertura := true,
+ coverageOutputDebug := false,
+ coverageOutputTeamCity := false,
+ coverageScalacPluginVersion := defaultScoverageVersion
+ )
override def buildSettings: Seq[Setting[_]] = super.buildSettings ++
- addCommandAlias("coverage", ";set coverageEnabled in ThisBuild := true") ++
- addCommandAlias("coverageOn", ";set coverageEnabled in ThisBuild := true") ++
- addCommandAlias("coverageOff", ";set coverageEnabled in ThisBuild := false")
+ addCommandAlias("coverage", ";set ThisBuild / coverageEnabled := true") ++
+ addCommandAlias("coverageOn", ";set ThisBuild / coverageEnabled := true") ++
+ addCommandAlias("coverageOff", ";set ThisBuild / coverageEnabled := false")
override def projectSettings: Seq[Setting[_]] = Seq(
ivyConfigurations += ScoveragePluginConfig,
coverageReport := coverageReport0.value,
coverageAggregate := coverageAggregate0.value,
- aggregate in coverageAggregate := false
+ coverageAggregate / aggregate := false,
+ coverageDataDir := crossTarget.value
) ++ coverageSettings ++ scalacSettings
private lazy val coverageSettings = Seq(
- libraryDependencies ++= {
- if (coverageEnabled.value)
+ libraryDependencies ++= {
+ if (coverageEnabled.value) {
Seq(
- // We only add for "compile"" because of macros. This setting could be optimed to just "test" if the handling
+ // We only add for "compile" because of macros. This setting could be optimed to just "test" if the handling
// of macro coverage was improved.
- OrgScoverage %% (scalacRuntime(libraryDependencies.value)) % coverageScalacPluginVersion.value,
+ orgScoverage %% (scalacRuntime(
+ libraryDependencies.value
+ )) % coverageScalacPluginVersion.value,
// We don't want to instrument the test code itself, nor add to a pom when published with coverage enabled.
- OrgScoverage %% ScalacPluginArtifact % coverageScalacPluginVersion.value % ScoveragePluginConfig.name
+ (orgScoverage %% scalacPluginArtifact % coverageScalacPluginVersion.value % ScoveragePluginConfig.name)
+ .cross(CrossVersion.full)
)
- else
+ } else
Nil
}
)
private lazy val scalacSettings = Seq(
- scalacOptions in(Compile, compile) ++= {
+ Compile / compile / scalacOptions ++= {
val updateReport = update.value
if (coverageEnabled.value) {
- val scoverageDeps: Seq[File] = updateReport matching configurationFilter(ScoveragePluginConfig.name)
- val pluginPath: File = scoverageDeps.find(_.getAbsolutePath.contains(ScalacPluginArtifact)) match {
- case None => throw new Exception(s"Fatal: $ScalacPluginArtifact not in libraryDependencies")
+ val scoverageDeps: Seq[File] =
+ updateReport matching configurationFilter(ScoveragePluginConfig.name)
+ val pluginPath: File = scoverageDeps.find(
+ _.getAbsolutePath.contains(scalacPluginArtifact)
+ ) match {
+ case None =>
+ throw new Exception(
+ s"Fatal: $scalacPluginArtifact not in libraryDependencies"
+ )
case Some(pluginPath) => pluginPath
}
Seq(
Some(s"-Xplugin:${pluginPath.getAbsolutePath}"),
- Some(s"-P:scoverage:dataDir:${crossTarget.value.getAbsolutePath}/scoverage-data"),
- Option(coverageExcludedPackages.value.trim).filter(_.nonEmpty).map(v => s"-P:scoverage:excludedPackages:$v"),
- Option(coverageExcludedFiles.value.trim).filter(_.nonEmpty).map(v => s"-P:scoverage:excludedFiles:$v"),
+ Some(
+ s"-P:scoverage:dataDir:${coverageDataDir.value.getAbsolutePath}/scoverage-data"
+ ),
+ Option(coverageExcludedPackages.value.trim)
+ .filter(_.nonEmpty)
+ .map(v => s"-P:scoverage:excludedPackages:$v"),
+ Option(coverageExcludedFiles.value.trim)
+ .filter(_.nonEmpty)
+ .map(v => s"-P:scoverage:excludedFiles:$v"),
+ Some("-P:scoverage:reportTestName"),
// rangepos is broken in some releases of scala so option to turn it off
if (coverageHighlighting.value) Some("-Yrangepos") else None
).flatten
@@ -90,53 +119,64 @@ object ScoverageSbtPlugin extends AutoPlugin {
)
private def scalacRuntime(deps: Seq[ModuleID]): String = {
- ScalacRuntimeArtifact + optionalScalaJsSuffix(deps)
+ scalacRuntimeArtifact + optionalScalaJsSuffix(deps)
}
// returns "_sjs$sjsVersion" for Scala.js projects or "" otherwise
private def optionalScalaJsSuffix(deps: Seq[ModuleID]): String = {
- val sjsClassifier = deps.collectFirst {
- case moduleId if moduleId.organization == "org.scala-js" && moduleId.name == "scalajs-library" => moduleId.revision
- }.map(_.take(3)).map(sjsVersion => "_sjs" + sjsVersion)
+ val sjsClassifier = deps
+ .collectFirst {
+ case moduleId
+ if moduleId.organization == "org.scala-js" && moduleId.name == "scalajs-library" =>
+ moduleId.revision
+ }
+ .map(_.take(1))
+ .map(sjsVersion => "_sjs" + sjsVersion)
sjsClassifier getOrElse ""
}
private lazy val coverageReport0 = Def.task {
- val target = crossTarget.value
- val log = streams.value.log
+ val target = coverageDataDir.value
+ implicit val log = streams.value.log
log.info(s"Waiting for measurement data to sync...")
- Thread.sleep(1000) // have noticed some delay in writing on windows, hacky but works
+ Thread.sleep(
+ 1000
+ ) // have noticed some delay in writing on windows, hacky but works
loadCoverage(target, log) match {
case Some(cov) =>
writeReports(
target,
- (sourceDirectories in Compile).value,
+ (Compile / sourceDirectories).value,
cov,
coverageOutputCobertura.value,
coverageOutputXML.value,
coverageOutputHTML.value,
coverageOutputDebug.value,
coverageOutputTeamCity.value,
- sourceEncoding((scalacOptions in (Compile)).value),
- log)
+ sourceEncoding((Compile / scalacOptions).value),
+ log
+ )
- checkCoverage(cov, log, coverageMinimum.value, coverageFailOnMinimum.value)
+ CoverageMinimum.all.value
+ .checkCoverage(cov, coverageFailOnMinimum.value)
case None => log.warn("No coverage data, skipping reports")
}
}
private lazy val coverageAggregate0 = Def.task {
- val log = streams.value.log
+ implicit val log = streams.value.log
log.info(s"Aggregating coverage from subprojects...")
- val dataDirs = crossTarget.all(aggregateFilter).value map (_ / Constants.DataDir) filter (_.isDirectory)
+ val dataDirs = coverageDataDir
+ .all(aggregateFilter)
+ .value map (_ / Constants.DataDir) filter (_.isDirectory)
CoverageAggregator.aggregate(dataDirs) match {
case Some(cov) =>
writeReports(
- crossTarget.value,
+ coverageDataDir.value,
sourceDirectories.all(aggregateFilter).value.flatten,
cov,
coverageOutputCobertura.value,
@@ -144,27 +184,31 @@ object ScoverageSbtPlugin extends AutoPlugin {
coverageOutputHTML.value,
coverageOutputDebug.value,
coverageOutputTeamCity.value,
- sourceEncoding((scalacOptions in (Compile)).value),
- log)
+ sourceEncoding((Compile / scalacOptions).value),
+ log
+ )
val cfmt = cov.statementCoverageFormatted
log.info(s"Aggregation complete. Coverage was [$cfmt]")
- checkCoverage(cov, log, coverageMinimum.value, coverageFailOnMinimum.value)
+ CoverageMinimum.all.value
+ .checkCoverage(cov, coverageFailOnMinimum.value)
case None =>
log.info("No subproject data to aggregate, skipping reports")
}
}
- private def writeReports(crossTarget: File,
- compileSourceDirectories: Seq[File],
- coverage: Coverage,
- coverageOutputCobertura: Boolean,
- coverageOutputXML: Boolean,
- coverageOutputHTML: Boolean,
- coverageDebug: Boolean,
- coverageOutputTeamCity: Boolean,
- coverageSourceEncoding: Option[String],
- log: Logger): Unit = {
+ private def writeReports(
+ crossTarget: File,
+ compileSourceDirectories: Seq[File],
+ coverage: Coverage,
+ coverageOutputCobertura: Boolean,
+ coverageOutputXML: Boolean,
+ coverageOutputHTML: Boolean,
+ coverageDebug: Boolean,
+ coverageOutputTeamCity: Boolean,
+ coverageSourceEncoding: Option[String],
+ log: Logger
+ ): Unit = {
log.info(s"Generating scoverage reports...")
val coberturaDir = crossTarget / "coverage-report"
@@ -173,24 +217,46 @@ object ScoverageSbtPlugin extends AutoPlugin {
reportDir.mkdirs()
if (coverageOutputCobertura) {
- new CoberturaXmlWriter(compileSourceDirectories, coberturaDir).write(coverage)
- log.info(s"Written Cobertura report [${coberturaDir.getAbsolutePath}/cobertura.xml]")
+ new CoberturaXmlWriter(compileSourceDirectories, coberturaDir).write(
+ coverage
+ )
+ log.info(
+ s"Written Cobertura report [${coberturaDir.getAbsolutePath}/cobertura.xml]"
+ )
}
if (coverageOutputXML) {
- new ScoverageXmlWriter(compileSourceDirectories, reportDir, false).write(coverage)
+ new ScoverageXmlWriter(compileSourceDirectories, reportDir, false).write(
+ coverage
+ )
if (coverageDebug) {
- new ScoverageXmlWriter(compileSourceDirectories, reportDir, true).write(coverage)
+ new ScoverageXmlWriter(compileSourceDirectories, reportDir, true).write(
+ coverage
+ )
}
- log.info(s"Written XML coverage report [${reportDir.getAbsolutePath}/scoverage.xml]")
+ log.info(
+ s"Written XML coverage report [${reportDir.getAbsolutePath}/scoverage.xml]"
+ )
}
if (coverageOutputHTML) {
- new ScoverageHtmlWriter(compileSourceDirectories, reportDir, coverageSourceEncoding).write(coverage)
- log.info(s"Written HTML coverage report [${reportDir.getAbsolutePath}/index.html]")
+ new ScoverageHtmlWriter(
+ compileSourceDirectories,
+ reportDir,
+ coverageSourceEncoding
+ ).write(coverage)
+ log.info(
+ s"Written HTML coverage report [${reportDir.getAbsolutePath}/index.html]"
+ )
}
if (coverageOutputTeamCity) {
- reportToTeamcity(coverage, coverageOutputHTML, reportDir, crossTarget, log)
+ reportToTeamcity(
+ coverage,
+ coverageOutputHTML,
+ reportDir,
+ crossTarget,
+ log
+ )
log.info("Written coverage report to TeamCity")
}
@@ -199,24 +265,42 @@ object ScoverageSbtPlugin extends AutoPlugin {
log.info("Coverage reports completed")
}
- private def reportToTeamcity(coverage: Coverage,
- createCoverageZip: Boolean,
- reportDir: File,
- crossTarget: File,
- log: Logger) {
+ private def reportToTeamcity(
+ coverage: Coverage,
+ createCoverageZip: Boolean,
+ reportDir: File,
+ crossTarget: File,
+ log: Logger
+ ) {
- def statsKeyValue(key: String, value: Int): String = s"##teamcity[buildStatisticValue key='$key' value='$value']"
+ def statsKeyValue(key: String, value: Int): String =
+ s"##teamcity[buildStatisticValue key='$key' value='$value']"
// Log statement coverage as per: https://devnet.jetbrains.com/message/5467985
- log.info(statsKeyValue("CodeCoverageAbsSCovered", coverage.invokedStatementCount))
+ log.info(
+ statsKeyValue("CodeCoverageAbsSCovered", coverage.invokedStatementCount)
+ )
log.info(statsKeyValue("CodeCoverageAbsSTotal", coverage.statementCount))
+ log.info(
+ statsKeyValue("CodeCoverageAbsRCovered", coverage.invokedBranchesCount)
+ )
+ log.info(statsKeyValue("CodeCoverageAbsRTotal", coverage.branchCount))
// Log branch coverage as a custom metrics (in percent)
- log.info(statsKeyValue("CodeCoverageBranch", "%.0f".format(coverage.branchCoveragePercent).toInt))
+ log.info(
+ statsKeyValue(
+ "CodeCoverageBranch",
+ "%.0f".format(coverage.branchCoveragePercent).toInt
+ )
+ )
// Create the coverage report for teamcity (HTML files)
if (createCoverageZip)
- IO.zip(Path.allSubpaths(reportDir), crossTarget / "coverage.zip")
+ IO.zip(
+ Path.allSubpaths(reportDir),
+ crossTarget / "coverage.zip",
+ Some(Instant.now().toEpochMilli())
+ )
}
private def loadCoverage(crossTarget: File, log: Logger): Option[Coverage] = {
@@ -241,32 +325,6 @@ object ScoverageSbtPlugin extends AutoPlugin {
}
}
- private def checkCoverage(coverage: Coverage,
- log: Logger,
- min: Double,
- failOnMin: Boolean): Unit = {
-
- val cper = coverage.statementCoveragePercent
- val cfmt = coverage.statementCoverageFormatted
-
- // check for default minimum
- if (min > 0) {
- def is100(d: Double) = Math.abs(100 - d) <= 0.00001
-
- if (is100(min) && is100(cper)) {
- log.info(s"100% Coverage !")
- } else if (min > cper) {
- log.error(s"Coverage is below minimum [$cfmt% < $min%]")
- if (failOnMin)
- throw new RuntimeException("Coverage minimum was not reached")
- } else {
- log.info(s"Coverage is above minimum [$cfmt% > $min%]")
- }
- }
-
- log.info(s"All done. Coverage was [$cfmt%]")
- }
-
private def sourceEncoding(scalacOptions: Seq[String]): Option[String] = {
val i = scalacOptions.indexOf("-encoding") + 1
if (i > 0 && i < scalacOptions.length) Some(scalacOptions(i)) else None
diff --git a/src/sbt-test/scoverage/aggregate-only/build.sbt b/src/sbt-test/scoverage/aggregate-only/build.sbt
index 9036ce72..c2c6ed97 100644
--- a/src/sbt-test/scoverage/aggregate-only/build.sbt
+++ b/src/sbt-test/scoverage/aggregate-only/build.sbt
@@ -1,23 +1,21 @@
/*
The projects test aggregation of coverage reports from two sub-projects.
The sub-projects are in the directories partA and partB.
-*/
+ */
lazy val commonSettings = Seq(
organization := "org.scoverage",
version := "0.1.0",
- scalaVersion := "2.12.8"
+ scalaVersion := "2.13.6"
)
-lazy val specs2Lib = "org.specs2" %% "specs2" % "2.5" % "test"
-
def module(name: String) = {
val id = s"part$name"
Project(id = id, base = file(id))
.settings(commonSettings: _*)
.settings(
Keys.name := name,
- libraryDependencies += specs2Lib
+ libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
)
}
@@ -25,16 +23,18 @@ lazy val partA = module("A")
lazy val partB = module("B")
lazy val root = (project in file("."))
- .settings(commonSettings:_*)
+ .settings(commonSettings: _*)
.settings(
name := "root",
- test := { }
- ).aggregate(
+ test := {}
+ )
+ .aggregate(
partA,
partB
)
-resolvers in ThisBuild ++= {
- if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots"))
+ThisBuild / resolvers ++= {
+ if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT")))
+ Seq(Resolver.sonatypeRepo("snapshots"))
else Seq.empty
}
diff --git a/src/sbt-test/scoverage/aggregate-only/partA/src/main/scala/org/scoverage/issue53/part/a/AdderScala.scala b/src/sbt-test/scoverage/aggregate-only/partA/src/main/scala/org/scoverage/issue53/part/a/AdderScala.scala
index 30415c1d..96b580e3 100644
--- a/src/sbt-test/scoverage/aggregate-only/partA/src/main/scala/org/scoverage/issue53/part/a/AdderScala.scala
+++ b/src/sbt-test/scoverage/aggregate-only/partA/src/main/scala/org/scoverage/issue53/part/a/AdderScala.scala
@@ -1,8 +1,7 @@
package org.scoverage.issue53.part.a
-/**
- * Created by Mikhail Kokho on 7/10/2015.
- */
+/** Created by Mikhail Kokho on 7/10/2015.
+ */
object AdderScala {
def add(x: Int, y: Int) = x + y
diff --git a/src/sbt-test/scoverage/aggregate-only/partA/src/test/scala/AdderTestSuite.scala b/src/sbt-test/scoverage/aggregate-only/partA/src/test/scala/AdderTestSuite.scala
index 63efd2b9..71204c58 100644
--- a/src/sbt-test/scoverage/aggregate-only/partA/src/test/scala/AdderTestSuite.scala
+++ b/src/sbt-test/scoverage/aggregate-only/partA/src/test/scala/AdderTestSuite.scala
@@ -1,13 +1,10 @@
-import org.specs2.mutable._
+import munit.FunSuite
import org.scoverage.issue53.part.a.AdderScala
-/**
- * Created by Mikhail Kokho on 7/10/2015.
- */
-class AdderTestSuite extends Specification {
- "Adder" should {
- "sum two numbers" in {
- AdderScala.add(1, 2) mustEqual 3
- }
+/** Created by Mikhail Kokho on 7/10/2015.
+ */
+class AdderTestSuite extends FunSuite {
+ test("Adder should sum two numbers") {
+ assertEquals(AdderScala.add(1, 2), 3)
}
}
diff --git a/src/sbt-test/scoverage/aggregate-only/partB/src/main/scala/org/scoverage/issue53/part/b/SubtractorScala.scala b/src/sbt-test/scoverage/aggregate-only/partB/src/main/scala/org/scoverage/issue53/part/b/SubtractorScala.scala
index e6da85fd..fbb7dcda 100644
--- a/src/sbt-test/scoverage/aggregate-only/partB/src/main/scala/org/scoverage/issue53/part/b/SubtractorScala.scala
+++ b/src/sbt-test/scoverage/aggregate-only/partB/src/main/scala/org/scoverage/issue53/part/b/SubtractorScala.scala
@@ -1,9 +1,7 @@
-
package org.scoverage.issue53.part.b
-/**
- * Created by Mikhail Kokho on 7/10/2015.
- */
+/** Created by Mikhail Kokho on 7/10/2015.
+ */
object SubtractorScala {
def minus(x: Int, y: Int) = x - y
diff --git a/src/sbt-test/scoverage/aggregate-only/partB/src/test/scala/SubtractorTestSuite.scala b/src/sbt-test/scoverage/aggregate-only/partB/src/test/scala/SubtractorTestSuite.scala
index 97c5266f..6b2ededf 100644
--- a/src/sbt-test/scoverage/aggregate-only/partB/src/test/scala/SubtractorTestSuite.scala
+++ b/src/sbt-test/scoverage/aggregate-only/partB/src/test/scala/SubtractorTestSuite.scala
@@ -1,14 +1,10 @@
-import org.specs2.mutable._
+import munit.FunSuite
import org.scoverage.issue53.part.b.SubtractorScala
-/**
- * Created by Mikhail Kokho on 7/10/2015.
- */
-class SubtractorTestSuite extends Specification {
- "Subtractor" should {
- "subtract two numbers" in {
- SubtractorScala.minus(2, 1) mustEqual 1
- }
+/** Created by Mikhail Kokho on 7/10/2015.
+ */
+class SubtractorTestSuite extends FunSuite {
+ test("Subtractor should subtract two numbers") {
+ assertEquals(SubtractorScala.minus(2, 1), 1)
}
}
-
diff --git a/src/sbt-test/scoverage/aggregate-only/project/plugins.sbt b/src/sbt-test/scoverage/aggregate-only/project/plugins.sbt
index 8f2837b3..8d349239 100644
--- a/src/sbt-test/scoverage/aggregate-only/project/plugins.sbt
+++ b/src/sbt-test/scoverage/aggregate-only/project/plugins.sbt
@@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse(
"plugin.version",
throw new RuntimeException(
"""|The system property 'plugin.version' is not defined.
- |Specify this property using the scriptedLaunchOpts -D.""".stripMargin))
+ |Specify this property using the scriptedLaunchOpts -D.""".stripMargin
+ )
+)
addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion)
diff --git a/src/sbt-test/scoverage/aggregate-only/test b/src/sbt-test/scoverage/aggregate-only/test
index fb0d70f6..26983121 100644
--- a/src/sbt-test/scoverage/aggregate-only/test
+++ b/src/sbt-test/scoverage/aggregate-only/test
@@ -3,12 +3,12 @@
> coverage
> test
# There should be scoverage-data directories for modules
-$ exists partA/target/scala-2.12/scoverage-data
-$ exists partB/target/scala-2.12/scoverage-data
+$ exists partA/target/scala-2.13/scoverage-data
+$ exists partB/target/scala-2.13/scoverage-data
# Generate aggregated reports without generating per-module reports first
> coverageAggregate
# There shouldn't be scoverage-report directories for modules
--$ exists partA/target/scala-2.12/scoverage-report
--$ exists partB/target/scala-2.12/scoverage-report
+-$ exists partA/target/scala-2.13/scoverage-report
+-$ exists partB/target/scala-2.13/scoverage-report
# There should be a root scoverage-report directory
-$ exists target/scala-2.12/scoverage-report
\ No newline at end of file
+$ exists target/scala-2.13/scoverage-report
diff --git a/src/sbt-test/scoverage/aggregate/build.sbt b/src/sbt-test/scoverage/aggregate/build.sbt
index 9036ce72..c2c6ed97 100644
--- a/src/sbt-test/scoverage/aggregate/build.sbt
+++ b/src/sbt-test/scoverage/aggregate/build.sbt
@@ -1,23 +1,21 @@
/*
The projects test aggregation of coverage reports from two sub-projects.
The sub-projects are in the directories partA and partB.
-*/
+ */
lazy val commonSettings = Seq(
organization := "org.scoverage",
version := "0.1.0",
- scalaVersion := "2.12.8"
+ scalaVersion := "2.13.6"
)
-lazy val specs2Lib = "org.specs2" %% "specs2" % "2.5" % "test"
-
def module(name: String) = {
val id = s"part$name"
Project(id = id, base = file(id))
.settings(commonSettings: _*)
.settings(
Keys.name := name,
- libraryDependencies += specs2Lib
+ libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
)
}
@@ -25,16 +23,18 @@ lazy val partA = module("A")
lazy val partB = module("B")
lazy val root = (project in file("."))
- .settings(commonSettings:_*)
+ .settings(commonSettings: _*)
.settings(
name := "root",
- test := { }
- ).aggregate(
+ test := {}
+ )
+ .aggregate(
partA,
partB
)
-resolvers in ThisBuild ++= {
- if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots"))
+ThisBuild / resolvers ++= {
+ if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT")))
+ Seq(Resolver.sonatypeRepo("snapshots"))
else Seq.empty
}
diff --git a/src/sbt-test/scoverage/aggregate/partA/src/main/scala/org/scoverage/issue53/part/a/AdderScala.scala b/src/sbt-test/scoverage/aggregate/partA/src/main/scala/org/scoverage/issue53/part/a/AdderScala.scala
index 30415c1d..96b580e3 100644
--- a/src/sbt-test/scoverage/aggregate/partA/src/main/scala/org/scoverage/issue53/part/a/AdderScala.scala
+++ b/src/sbt-test/scoverage/aggregate/partA/src/main/scala/org/scoverage/issue53/part/a/AdderScala.scala
@@ -1,8 +1,7 @@
package org.scoverage.issue53.part.a
-/**
- * Created by Mikhail Kokho on 7/10/2015.
- */
+/** Created by Mikhail Kokho on 7/10/2015.
+ */
object AdderScala {
def add(x: Int, y: Int) = x + y
diff --git a/src/sbt-test/scoverage/aggregate/partA/src/test/scala/AdderTestSuite.scala b/src/sbt-test/scoverage/aggregate/partA/src/test/scala/AdderTestSuite.scala
index 63efd2b9..71204c58 100644
--- a/src/sbt-test/scoverage/aggregate/partA/src/test/scala/AdderTestSuite.scala
+++ b/src/sbt-test/scoverage/aggregate/partA/src/test/scala/AdderTestSuite.scala
@@ -1,13 +1,10 @@
-import org.specs2.mutable._
+import munit.FunSuite
import org.scoverage.issue53.part.a.AdderScala
-/**
- * Created by Mikhail Kokho on 7/10/2015.
- */
-class AdderTestSuite extends Specification {
- "Adder" should {
- "sum two numbers" in {
- AdderScala.add(1, 2) mustEqual 3
- }
+/** Created by Mikhail Kokho on 7/10/2015.
+ */
+class AdderTestSuite extends FunSuite {
+ test("Adder should sum two numbers") {
+ assertEquals(AdderScala.add(1, 2), 3)
}
}
diff --git a/src/sbt-test/scoverage/aggregate/partB/src/main/scala/org/scoverage/issue53/part/b/SubtractorScala.scala b/src/sbt-test/scoverage/aggregate/partB/src/main/scala/org/scoverage/issue53/part/b/SubtractorScala.scala
index e6da85fd..fbb7dcda 100644
--- a/src/sbt-test/scoverage/aggregate/partB/src/main/scala/org/scoverage/issue53/part/b/SubtractorScala.scala
+++ b/src/sbt-test/scoverage/aggregate/partB/src/main/scala/org/scoverage/issue53/part/b/SubtractorScala.scala
@@ -1,9 +1,7 @@
-
package org.scoverage.issue53.part.b
-/**
- * Created by Mikhail Kokho on 7/10/2015.
- */
+/** Created by Mikhail Kokho on 7/10/2015.
+ */
object SubtractorScala {
def minus(x: Int, y: Int) = x - y
diff --git a/src/sbt-test/scoverage/aggregate/partB/src/test/scala/SubtractorTestSuite.scala b/src/sbt-test/scoverage/aggregate/partB/src/test/scala/SubtractorTestSuite.scala
index 97c5266f..4bec321a 100644
--- a/src/sbt-test/scoverage/aggregate/partB/src/test/scala/SubtractorTestSuite.scala
+++ b/src/sbt-test/scoverage/aggregate/partB/src/test/scala/SubtractorTestSuite.scala
@@ -1,14 +1,10 @@
-import org.specs2.mutable._
+import munit.FunSuite
import org.scoverage.issue53.part.b.SubtractorScala
-/**
- * Created by Mikhail Kokho on 7/10/2015.
- */
-class SubtractorTestSuite extends Specification {
- "Subtractor" should {
- "subtract two numbers" in {
- SubtractorScala.minus(2, 1) mustEqual 1
- }
+/** Created by Mikhail Kokho on 7/10/2015.
+ */
+class SubtractorTestSuite extends FunSuite {
+ test("Subtractor should substract two numbers") {
+ assertEquals(SubtractorScala.minus(2, 1), 1)
}
}
-
diff --git a/src/sbt-test/scoverage/aggregate/project/build.properties b/src/sbt-test/scoverage/aggregate/project/build.properties
new file mode 100644
index 00000000..10fd9eee
--- /dev/null
+++ b/src/sbt-test/scoverage/aggregate/project/build.properties
@@ -0,0 +1 @@
+sbt.version=1.5.5
diff --git a/src/sbt-test/scoverage/aggregate/project/plugins.sbt b/src/sbt-test/scoverage/aggregate/project/plugins.sbt
index 8f2837b3..8d349239 100644
--- a/src/sbt-test/scoverage/aggregate/project/plugins.sbt
+++ b/src/sbt-test/scoverage/aggregate/project/plugins.sbt
@@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse(
"plugin.version",
throw new RuntimeException(
"""|The system property 'plugin.version' is not defined.
- |Specify this property using the scriptedLaunchOpts -D.""".stripMargin))
+ |Specify this property using the scriptedLaunchOpts -D.""".stripMargin
+ )
+)
addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion)
diff --git a/src/sbt-test/scoverage/aggregate/test b/src/sbt-test/scoverage/aggregate/test
index 9475fbbb..2a4f5fc3 100644
--- a/src/sbt-test/scoverage/aggregate/test
+++ b/src/sbt-test/scoverage/aggregate/test
@@ -3,12 +3,12 @@
> coverage
> test
# There should be scoverage-data directory
-$ exists partA/target/scala-2.12/scoverage-data
-$ exists partB/target/scala-2.12/scoverage-data
+$ exists partA/target/scala-2.13/scoverage-data
+$ exists partB/target/scala-2.13/scoverage-data
> coverageReport
# There should be scoverage-report directory
-$ exists partA/target/scala-2.12/scoverage-report
-$ exists partB/target/scala-2.12/scoverage-report
+$ exists partA/target/scala-2.13/scoverage-report
+$ exists partB/target/scala-2.13/scoverage-report
> coverageAggregate
# There should be a root scoverage-report directory
-$ exists target/scala-2.12/scoverage-report
\ No newline at end of file
+$ exists target/scala-2.13/scoverage-report
diff --git a/src/sbt-test/scoverage/bad-coverage-file-branch/build.sbt b/src/sbt-test/scoverage/bad-coverage-file-branch/build.sbt
new file mode 100644
index 00000000..56f70037
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-file-branch/build.sbt
@@ -0,0 +1,19 @@
+version := "0.1"
+
+scalaVersion := "2.13.6"
+
+libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
+
+coverageMinimumBranchPerFile := 80
+
+coverageFailOnMinimum := true
+
+resolvers ++= {
+ if (
+ sys.props
+ .get("plugin.version")
+ .map(_.endsWith("-SNAPSHOT"))
+ .getOrElse(false)
+ ) Seq(Resolver.sonatypeRepo("snapshots"))
+ else Seq.empty
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-file-branch/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage-file-branch/project/plugins.sbt
new file mode 100644
index 00000000..8d349239
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-file-branch/project/plugins.sbt
@@ -0,0 +1,16 @@
+val pluginVersion = sys.props.getOrElse(
+ "plugin.version",
+ throw new RuntimeException(
+ """|The system property 'plugin.version' is not defined.
+ |Specify this property using the scriptedLaunchOpts -D.""".stripMargin
+ )
+)
+
+addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion)
+
+resolvers ++= {
+ if (pluginVersion.endsWith("-SNAPSHOT"))
+ Seq(Resolver.sonatypeRepo("snapshots"))
+ else
+ Seq.empty
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-file-branch/src/main/scala/one/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-file-branch/src/main/scala/one/BadCoverage.scala
new file mode 100644
index 00000000..300ec10c
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-file-branch/src/main/scala/one/BadCoverage.scala
@@ -0,0 +1,9 @@
+package one
+
+object BadCoverage {
+
+ def sum(num1: Int, num2: Int) = {
+ if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2
+ }
+
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-file-branch/src/main/scala/two/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-file-branch/src/main/scala/two/BadCoverage.scala
new file mode 100644
index 00000000..3ebc31da
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-file-branch/src/main/scala/two/BadCoverage.scala
@@ -0,0 +1,9 @@
+package two
+
+object BadCoverage {
+
+ def sum(num1: Int, num2: Int) = {
+ if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2
+ }
+
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-file-branch/src/test/scala/BadCoverageSpec.scala b/src/sbt-test/scoverage/bad-coverage-file-branch/src/test/scala/BadCoverageSpec.scala
new file mode 100644
index 00000000..801c7b43
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-file-branch/src/test/scala/BadCoverageSpec.scala
@@ -0,0 +1,16 @@
+import munit.FunSuite
+
+class BadCoverageSpec extends FunSuite {
+
+ test("one.BadCoverage should sum two numbers") {
+ assertEquals(one.BadCoverage.sum(1, 2), 3)
+ assertEquals(one.BadCoverage.sum(0, 3), 3)
+ assertEquals(one.BadCoverage.sum(3, 0), 3)
+ }
+
+ test("two.BadCoverage should sum two numbers") {
+ assertEquals(two.BadCoverage.sum(1, 2), 3)
+ assertEquals(two.BadCoverage.sum(0, 3), 3)
+ }
+
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-file-branch/test b/src/sbt-test/scoverage/bad-coverage-file-branch/test
new file mode 100644
index 00000000..45cbbb60
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-file-branch/test
@@ -0,0 +1,5 @@
+# run scoverage
+> clean
+> coverage
+> test
+-> coverageReport
diff --git a/src/sbt-test/scoverage/bad-coverage-file-stmt/build.sbt b/src/sbt-test/scoverage/bad-coverage-file-stmt/build.sbt
new file mode 100644
index 00000000..9da543b4
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-file-stmt/build.sbt
@@ -0,0 +1,19 @@
+version := "0.1"
+
+scalaVersion := "2.13.6"
+
+libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
+
+coverageMinimumStmtPerFile := 90
+
+coverageFailOnMinimum := true
+
+resolvers ++= {
+ if (
+ sys.props
+ .get("plugin.version")
+ .map(_.endsWith("-SNAPSHOT"))
+ .getOrElse(false)
+ ) Seq(Resolver.sonatypeRepo("snapshots"))
+ else Seq.empty
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-file-stmt/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage-file-stmt/project/plugins.sbt
new file mode 100644
index 00000000..8d349239
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-file-stmt/project/plugins.sbt
@@ -0,0 +1,16 @@
+val pluginVersion = sys.props.getOrElse(
+ "plugin.version",
+ throw new RuntimeException(
+ """|The system property 'plugin.version' is not defined.
+ |Specify this property using the scriptedLaunchOpts -D.""".stripMargin
+ )
+)
+
+addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion)
+
+resolvers ++= {
+ if (pluginVersion.endsWith("-SNAPSHOT"))
+ Seq(Resolver.sonatypeRepo("snapshots"))
+ else
+ Seq.empty
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-file-stmt/src/main/scala/one/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-file-stmt/src/main/scala/one/BadCoverage.scala
new file mode 100644
index 00000000..300ec10c
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-file-stmt/src/main/scala/one/BadCoverage.scala
@@ -0,0 +1,9 @@
+package one
+
+object BadCoverage {
+
+ def sum(num1: Int, num2: Int) = {
+ if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2
+ }
+
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-file-stmt/src/main/scala/two/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-file-stmt/src/main/scala/two/BadCoverage.scala
new file mode 100644
index 00000000..3ebc31da
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-file-stmt/src/main/scala/two/BadCoverage.scala
@@ -0,0 +1,9 @@
+package two
+
+object BadCoverage {
+
+ def sum(num1: Int, num2: Int) = {
+ if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2
+ }
+
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-file-stmt/src/test/scala/BadCoverageSpec.scala b/src/sbt-test/scoverage/bad-coverage-file-stmt/src/test/scala/BadCoverageSpec.scala
new file mode 100644
index 00000000..e6f4c197
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-file-stmt/src/test/scala/BadCoverageSpec.scala
@@ -0,0 +1,15 @@
+import munit.FunSuite
+
+class BadCoverageSpec extends FunSuite {
+
+ test("one.BadCoverage should sum two numbers") {
+ assertEquals(one.BadCoverage.sum(1, 2), 3)
+ assertEquals(one.BadCoverage.sum(0, 3), 3)
+ assertEquals(one.BadCoverage.sum(3, 0), 3)
+ }
+
+ test("two.BadCoverage should sum two numbers") {
+ assertEquals(two.BadCoverage.sum(1, 2), 3)
+ }
+
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-file-stmt/test b/src/sbt-test/scoverage/bad-coverage-file-stmt/test
new file mode 100644
index 00000000..45cbbb60
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-file-stmt/test
@@ -0,0 +1,5 @@
+# run scoverage
+> clean
+> coverage
+> test
+-> coverageReport
diff --git a/src/sbt-test/scoverage/bad-coverage-package-branch/build.sbt b/src/sbt-test/scoverage/bad-coverage-package-branch/build.sbt
new file mode 100644
index 00000000..748cf6e4
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-package-branch/build.sbt
@@ -0,0 +1,19 @@
+version := "0.1"
+
+scalaVersion := "2.13.6"
+
+libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
+
+coverageMinimumBranchPerPackage := 80
+
+coverageFailOnMinimum := true
+
+resolvers ++= {
+ if (
+ sys.props
+ .get("plugin.version")
+ .map(_.endsWith("-SNAPSHOT"))
+ .getOrElse(false)
+ ) Seq(Resolver.sonatypeRepo("snapshots"))
+ else Seq.empty
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-package-branch/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage-package-branch/project/plugins.sbt
new file mode 100644
index 00000000..8d349239
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-package-branch/project/plugins.sbt
@@ -0,0 +1,16 @@
+val pluginVersion = sys.props.getOrElse(
+ "plugin.version",
+ throw new RuntimeException(
+ """|The system property 'plugin.version' is not defined.
+ |Specify this property using the scriptedLaunchOpts -D.""".stripMargin
+ )
+)
+
+addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion)
+
+resolvers ++= {
+ if (pluginVersion.endsWith("-SNAPSHOT"))
+ Seq(Resolver.sonatypeRepo("snapshots"))
+ else
+ Seq.empty
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-package-branch/src/main/scala/one/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-package-branch/src/main/scala/one/BadCoverage.scala
new file mode 100644
index 00000000..300ec10c
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-package-branch/src/main/scala/one/BadCoverage.scala
@@ -0,0 +1,9 @@
+package one
+
+object BadCoverage {
+
+ def sum(num1: Int, num2: Int) = {
+ if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2
+ }
+
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-package-branch/src/main/scala/two/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-package-branch/src/main/scala/two/BadCoverage.scala
new file mode 100644
index 00000000..3ebc31da
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-package-branch/src/main/scala/two/BadCoverage.scala
@@ -0,0 +1,9 @@
+package two
+
+object BadCoverage {
+
+ def sum(num1: Int, num2: Int) = {
+ if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2
+ }
+
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-package-branch/src/test/scala/BadCoverageSpec.scala b/src/sbt-test/scoverage/bad-coverage-package-branch/src/test/scala/BadCoverageSpec.scala
new file mode 100644
index 00000000..801c7b43
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-package-branch/src/test/scala/BadCoverageSpec.scala
@@ -0,0 +1,16 @@
+import munit.FunSuite
+
+class BadCoverageSpec extends FunSuite {
+
+ test("one.BadCoverage should sum two numbers") {
+ assertEquals(one.BadCoverage.sum(1, 2), 3)
+ assertEquals(one.BadCoverage.sum(0, 3), 3)
+ assertEquals(one.BadCoverage.sum(3, 0), 3)
+ }
+
+ test("two.BadCoverage should sum two numbers") {
+ assertEquals(two.BadCoverage.sum(1, 2), 3)
+ assertEquals(two.BadCoverage.sum(0, 3), 3)
+ }
+
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-package-branch/test b/src/sbt-test/scoverage/bad-coverage-package-branch/test
new file mode 100644
index 00000000..45cbbb60
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-package-branch/test
@@ -0,0 +1,5 @@
+# run scoverage
+> clean
+> coverage
+> test
+-> coverageReport
diff --git a/src/sbt-test/scoverage/bad-coverage-package-stmt/build.sbt b/src/sbt-test/scoverage/bad-coverage-package-stmt/build.sbt
new file mode 100644
index 00000000..18176ee4
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-package-stmt/build.sbt
@@ -0,0 +1,19 @@
+version := "0.1"
+
+scalaVersion := "2.13.6"
+
+libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
+
+coverageMinimumStmtPerPackage := 80
+
+coverageFailOnMinimum := true
+
+resolvers ++= {
+ if (
+ sys.props
+ .get("plugin.version")
+ .map(_.endsWith("-SNAPSHOT"))
+ .getOrElse(false)
+ ) Seq(Resolver.sonatypeRepo("snapshots"))
+ else Seq.empty
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-package-stmt/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage-package-stmt/project/plugins.sbt
new file mode 100644
index 00000000..8d349239
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-package-stmt/project/plugins.sbt
@@ -0,0 +1,16 @@
+val pluginVersion = sys.props.getOrElse(
+ "plugin.version",
+ throw new RuntimeException(
+ """|The system property 'plugin.version' is not defined.
+ |Specify this property using the scriptedLaunchOpts -D.""".stripMargin
+ )
+)
+
+addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion)
+
+resolvers ++= {
+ if (pluginVersion.endsWith("-SNAPSHOT"))
+ Seq(Resolver.sonatypeRepo("snapshots"))
+ else
+ Seq.empty
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-package-stmt/src/main/scala/one/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-package-stmt/src/main/scala/one/BadCoverage.scala
new file mode 100644
index 00000000..300ec10c
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-package-stmt/src/main/scala/one/BadCoverage.scala
@@ -0,0 +1,9 @@
+package one
+
+object BadCoverage {
+
+ def sum(num1: Int, num2: Int) = {
+ if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2
+ }
+
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-package-stmt/src/main/scala/two/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-package-stmt/src/main/scala/two/BadCoverage.scala
new file mode 100644
index 00000000..3ebc31da
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-package-stmt/src/main/scala/two/BadCoverage.scala
@@ -0,0 +1,9 @@
+package two
+
+object BadCoverage {
+
+ def sum(num1: Int, num2: Int) = {
+ if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2
+ }
+
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-package-stmt/src/test/scala/BadCoverageSpec.scala b/src/sbt-test/scoverage/bad-coverage-package-stmt/src/test/scala/BadCoverageSpec.scala
new file mode 100644
index 00000000..e6f4c197
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-package-stmt/src/test/scala/BadCoverageSpec.scala
@@ -0,0 +1,15 @@
+import munit.FunSuite
+
+class BadCoverageSpec extends FunSuite {
+
+ test("one.BadCoverage should sum two numbers") {
+ assertEquals(one.BadCoverage.sum(1, 2), 3)
+ assertEquals(one.BadCoverage.sum(0, 3), 3)
+ assertEquals(one.BadCoverage.sum(3, 0), 3)
+ }
+
+ test("two.BadCoverage should sum two numbers") {
+ assertEquals(two.BadCoverage.sum(1, 2), 3)
+ }
+
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-package-stmt/test b/src/sbt-test/scoverage/bad-coverage-package-stmt/test
new file mode 100644
index 00000000..45cbbb60
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-package-stmt/test
@@ -0,0 +1,5 @@
+# run scoverage
+> clean
+> coverage
+> test
+-> coverageReport
diff --git a/src/sbt-test/scoverage/bad-coverage-total-branch/build.sbt b/src/sbt-test/scoverage/bad-coverage-total-branch/build.sbt
new file mode 100644
index 00000000..33b3c8d2
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-total-branch/build.sbt
@@ -0,0 +1,19 @@
+version := "0.1"
+
+scalaVersion := "2.13.6"
+
+libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
+
+coverageMinimumBranchTotal := 80
+
+coverageFailOnMinimum := true
+
+resolvers ++= {
+ if (
+ sys.props
+ .get("plugin.version")
+ .map(_.endsWith("-SNAPSHOT"))
+ .getOrElse(false)
+ ) Seq(Resolver.sonatypeRepo("snapshots"))
+ else Seq.empty
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-total-branch/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage-total-branch/project/plugins.sbt
new file mode 100644
index 00000000..8d349239
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-total-branch/project/plugins.sbt
@@ -0,0 +1,16 @@
+val pluginVersion = sys.props.getOrElse(
+ "plugin.version",
+ throw new RuntimeException(
+ """|The system property 'plugin.version' is not defined.
+ |Specify this property using the scriptedLaunchOpts -D.""".stripMargin
+ )
+)
+
+addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion)
+
+resolvers ++= {
+ if (pluginVersion.endsWith("-SNAPSHOT"))
+ Seq(Resolver.sonatypeRepo("snapshots"))
+ else
+ Seq.empty
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-total-branch/src/main/scala/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-total-branch/src/main/scala/BadCoverage.scala
new file mode 100644
index 00000000..fd6887a7
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-total-branch/src/main/scala/BadCoverage.scala
@@ -0,0 +1,7 @@
+object BadCoverage {
+
+ def sum(num1: Int, num2: Int) = {
+ if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2
+ }
+
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-total-branch/src/test/scala/BadCoverageSpec.scala b/src/sbt-test/scoverage/bad-coverage-total-branch/src/test/scala/BadCoverageSpec.scala
new file mode 100644
index 00000000..eb4b4ec8
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-total-branch/src/test/scala/BadCoverageSpec.scala
@@ -0,0 +1,10 @@
+import munit.FunSuite
+
+class BadCoverageSpec extends FunSuite {
+
+ test("BadCoverage should sum two numbers") {
+ assertEquals(BadCoverage.sum(1, 2), 3)
+ assertEquals(BadCoverage.sum(0, 3), 3)
+ }
+
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-total-branch/test b/src/sbt-test/scoverage/bad-coverage-total-branch/test
new file mode 100644
index 00000000..45cbbb60
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-total-branch/test
@@ -0,0 +1,5 @@
+# run scoverage
+> clean
+> coverage
+> test
+-> coverageReport
diff --git a/src/sbt-test/scoverage/bad-coverage-total-stmt/build.sbt b/src/sbt-test/scoverage/bad-coverage-total-stmt/build.sbt
new file mode 100644
index 00000000..46ad59a2
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-total-stmt/build.sbt
@@ -0,0 +1,19 @@
+version := "0.1"
+
+scalaVersion := "2.13.6"
+
+libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
+
+coverageMinimumStmtTotal := 80
+
+coverageFailOnMinimum := true
+
+resolvers ++= {
+ if (
+ sys.props
+ .get("plugin.version")
+ .map(_.endsWith("-SNAPSHOT"))
+ .getOrElse(false)
+ ) Seq(Resolver.sonatypeRepo("snapshots"))
+ else Seq.empty
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-total-stmt/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage-total-stmt/project/plugins.sbt
new file mode 100644
index 00000000..8d349239
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-total-stmt/project/plugins.sbt
@@ -0,0 +1,16 @@
+val pluginVersion = sys.props.getOrElse(
+ "plugin.version",
+ throw new RuntimeException(
+ """|The system property 'plugin.version' is not defined.
+ |Specify this property using the scriptedLaunchOpts -D.""".stripMargin
+ )
+)
+
+addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion)
+
+resolvers ++= {
+ if (pluginVersion.endsWith("-SNAPSHOT"))
+ Seq(Resolver.sonatypeRepo("snapshots"))
+ else
+ Seq.empty
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-total-stmt/src/main/scala/one/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-total-stmt/src/main/scala/one/BadCoverage.scala
new file mode 100644
index 00000000..300ec10c
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-total-stmt/src/main/scala/one/BadCoverage.scala
@@ -0,0 +1,9 @@
+package one
+
+object BadCoverage {
+
+ def sum(num1: Int, num2: Int) = {
+ if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2
+ }
+
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-total-stmt/src/main/scala/two/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-total-stmt/src/main/scala/two/BadCoverage.scala
new file mode 100644
index 00000000..3ebc31da
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-total-stmt/src/main/scala/two/BadCoverage.scala
@@ -0,0 +1,9 @@
+package two
+
+object BadCoverage {
+
+ def sum(num1: Int, num2: Int) = {
+ if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2
+ }
+
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-total-stmt/src/test/scala/BadCoverageSpec.scala b/src/sbt-test/scoverage/bad-coverage-total-stmt/src/test/scala/BadCoverageSpec.scala
new file mode 100644
index 00000000..e487ec12
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-total-stmt/src/test/scala/BadCoverageSpec.scala
@@ -0,0 +1,11 @@
+import munit.FunSuite
+
+class BadCoverageSpec extends FunSuite {
+
+ test("one.BadCoverage should sum two numbers") {
+ assertEquals(one.BadCoverage.sum(1, 2), 3)
+ assertEquals(one.BadCoverage.sum(0, 3), 3)
+ assertEquals(one.BadCoverage.sum(3, 0), 3)
+ }
+
+}
diff --git a/src/sbt-test/scoverage/bad-coverage-total-stmt/test b/src/sbt-test/scoverage/bad-coverage-total-stmt/test
new file mode 100644
index 00000000..45cbbb60
--- /dev/null
+++ b/src/sbt-test/scoverage/bad-coverage-total-stmt/test
@@ -0,0 +1,5 @@
+# run scoverage
+> clean
+> coverage
+> test
+-> coverageReport
diff --git a/src/sbt-test/scoverage/bad-coverage/build.sbt b/src/sbt-test/scoverage/bad-coverage/build.sbt
index c786340d..502f94a2 100644
--- a/src/sbt-test/scoverage/bad-coverage/build.sbt
+++ b/src/sbt-test/scoverage/bad-coverage/build.sbt
@@ -1,14 +1,15 @@
version := "0.1"
-scalaVersion := "2.12.8"
+scalaVersion := "2.13.6"
-libraryDependencies += "org.specs2" %% "specs2" % "2.5" % "test"
+libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
coverageMinimum := 80
coverageFailOnMinimum := true
resolvers ++= {
- if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots"))
+ if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT")))
+ Seq(Resolver.sonatypeRepo("snapshots"))
else Seq.empty
}
diff --git a/src/sbt-test/scoverage/bad-coverage/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage/project/plugins.sbt
index 8f2837b3..8d349239 100644
--- a/src/sbt-test/scoverage/bad-coverage/project/plugins.sbt
+++ b/src/sbt-test/scoverage/bad-coverage/project/plugins.sbt
@@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse(
"plugin.version",
throw new RuntimeException(
"""|The system property 'plugin.version' is not defined.
- |Specify this property using the scriptedLaunchOpts -D.""".stripMargin))
+ |Specify this property using the scriptedLaunchOpts -D.""".stripMargin
+ )
+)
addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion)
diff --git a/src/sbt-test/scoverage/bad-coverage/src/main/scala/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage/src/main/scala/BadCoverage.scala
index 9735241d..29663d06 100644
--- a/src/sbt-test/scoverage/bad-coverage/src/main/scala/BadCoverage.scala
+++ b/src/sbt-test/scoverage/bad-coverage/src/main/scala/BadCoverage.scala
@@ -7,4 +7,4 @@ object BadCoverage {
def mult(num1: Int, num2: Int) = {
num1 * num2
}
-}
\ No newline at end of file
+}
diff --git a/src/sbt-test/scoverage/bad-coverage/src/test/scala/BadCoverageSpec.scala b/src/sbt-test/scoverage/bad-coverage/src/test/scala/BadCoverageSpec.scala
index 16ce924b..1faa5e5a 100644
--- a/src/sbt-test/scoverage/bad-coverage/src/test/scala/BadCoverageSpec.scala
+++ b/src/sbt-test/scoverage/bad-coverage/src/test/scala/BadCoverageSpec.scala
@@ -1,13 +1,10 @@
-import org.specs2.mutable._
+import munit.FunSuite
-/**
- * Created by tbarke001c on 7/8/14.
- */
-class BadCoverageSpec extends Specification {
+/** Created by tbarke001c on 7/8/14.
+ */
+class BadCoverageSpec extends FunSuite {
- "BadCoverage" should {
- "sum two numbers" in {
- BadCoverage.sum(1, 2) mustEqual 3
- }
+ test("BadCoverage should sum two numbers") {
+ assertEquals(BadCoverage.sum(1, 2), 3)
}
}
diff --git a/src/sbt-test/scoverage/coverage-off/build.sbt b/src/sbt-test/scoverage/coverage-off/build.sbt
index c786340d..f24ad2a8 100644
--- a/src/sbt-test/scoverage/coverage-off/build.sbt
+++ b/src/sbt-test/scoverage/coverage-off/build.sbt
@@ -1,14 +1,21 @@
version := "0.1"
-scalaVersion := "2.12.8"
+scalaVersion := "2.13.6"
-libraryDependencies += "org.specs2" %% "specs2" % "2.5" % "test"
+libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
coverageMinimum := 80
+coverageMinimumStmtTotal := 100
+coverageMinimumBranchTotal := 100
+coverageMinimumStmtPerPackage := 100
+coverageMinimumBranchPerPackage := 100
+coverageMinimumStmtPerFile := 100
+coverageMinimumBranchPerFile := 100
coverageFailOnMinimum := true
resolvers ++= {
- if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots"))
+ if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT")))
+ Seq(Resolver.sonatypeRepo("snapshots"))
else Seq.empty
}
diff --git a/src/sbt-test/scoverage/coverage-off/project/plugins.sbt b/src/sbt-test/scoverage/coverage-off/project/plugins.sbt
index 8f2837b3..8d349239 100644
--- a/src/sbt-test/scoverage/coverage-off/project/plugins.sbt
+++ b/src/sbt-test/scoverage/coverage-off/project/plugins.sbt
@@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse(
"plugin.version",
throw new RuntimeException(
"""|The system property 'plugin.version' is not defined.
- |Specify this property using the scriptedLaunchOpts -D.""".stripMargin))
+ |Specify this property using the scriptedLaunchOpts -D.""".stripMargin
+ )
+)
addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion)
diff --git a/src/sbt-test/scoverage/coverage-off/src/main/scala/GoodCoverage.scala b/src/sbt-test/scoverage/coverage-off/src/main/scala/GoodCoverage.scala
index f4f3ecae..ac6582bb 100644
--- a/src/sbt-test/scoverage/coverage-off/src/main/scala/GoodCoverage.scala
+++ b/src/sbt-test/scoverage/coverage-off/src/main/scala/GoodCoverage.scala
@@ -1,6 +1,7 @@
object GoodCoverage {
def sum(num1: Int, num2: Int) = {
- num1 + num2
+ if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2
}
-}
\ No newline at end of file
+
+}
diff --git a/src/sbt-test/scoverage/coverage-off/src/main/scala/two/GoodCoverage.scala b/src/sbt-test/scoverage/coverage-off/src/main/scala/two/GoodCoverage.scala
new file mode 100644
index 00000000..587e11e1
--- /dev/null
+++ b/src/sbt-test/scoverage/coverage-off/src/main/scala/two/GoodCoverage.scala
@@ -0,0 +1,9 @@
+package two
+
+object GoodCoverage {
+
+ def sum(num1: Int, num2: Int) = {
+ if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2
+ }
+
+}
diff --git a/src/sbt-test/scoverage/coverage-off/src/test/scala/GoodCoverageSpec.scala b/src/sbt-test/scoverage/coverage-off/src/test/scala/GoodCoverageSpec.scala
index cbf6a70d..44eec1c9 100644
--- a/src/sbt-test/scoverage/coverage-off/src/test/scala/GoodCoverageSpec.scala
+++ b/src/sbt-test/scoverage/coverage-off/src/test/scala/GoodCoverageSpec.scala
@@ -1,13 +1,19 @@
-import org.specs2.mutable._
+import munit.FunSuite
-/**
- * Created by tbarke001c on 7/8/14.
- */
-class GoodCoverageSpec extends Specification {
+/** Created by tbarke001c on 7/8/14.
+ */
+class GoodCoverageSpec extends FunSuite {
- "GoodCoverage" should {
- "sum two numbers" in {
- GoodCoverage.sum(1, 2) mustEqual 3
- }
+ test("GoodCoverage should sum two numbers") {
+ assertEquals(GoodCoverage.sum(1, 2), 3)
+ assertEquals(GoodCoverage.sum(0, 3), 3)
+ assertEquals(GoodCoverage.sum(3, 0), 3)
}
+
+ test("two.GoodCoverage should sum two numbers") {
+ assertEquals(two.GoodCoverage.sum(1, 2), 3)
+ assertEquals(two.GoodCoverage.sum(0, 3), 3)
+ assertEquals(two.GoodCoverage.sum(3, 0), 3)
+ }
+
}
diff --git a/src/sbt-test/scoverage/data-dir/build.sbt b/src/sbt-test/scoverage/data-dir/build.sbt
new file mode 100644
index 00000000..c18a8d52
--- /dev/null
+++ b/src/sbt-test/scoverage/data-dir/build.sbt
@@ -0,0 +1,17 @@
+version := "0.1"
+
+scalaVersion := "2.13.6"
+
+libraryDependencies += "org.specs2" %% "specs2-core" % "4.12.10" % "test"
+
+coverageDataDir := target.value / "custom-test"
+
+coverageMinimum := 80
+
+coverageFailOnMinimum := true
+
+resolvers ++= {
+ if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT")))
+ Seq(Resolver.sonatypeRepo("snapshots"))
+ else Seq.empty
+}
diff --git a/src/sbt-test/scoverage/data-dir/project/build.properties b/src/sbt-test/scoverage/data-dir/project/build.properties
new file mode 100644
index 00000000..67d27a1d
--- /dev/null
+++ b/src/sbt-test/scoverage/data-dir/project/build.properties
@@ -0,0 +1 @@
+sbt.version=1.5.3
diff --git a/src/sbt-test/scoverage/data-dir/project/plugins.sbt b/src/sbt-test/scoverage/data-dir/project/plugins.sbt
new file mode 100644
index 00000000..8d349239
--- /dev/null
+++ b/src/sbt-test/scoverage/data-dir/project/plugins.sbt
@@ -0,0 +1,16 @@
+val pluginVersion = sys.props.getOrElse(
+ "plugin.version",
+ throw new RuntimeException(
+ """|The system property 'plugin.version' is not defined.
+ |Specify this property using the scriptedLaunchOpts -D.""".stripMargin
+ )
+)
+
+addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion)
+
+resolvers ++= {
+ if (pluginVersion.endsWith("-SNAPSHOT"))
+ Seq(Resolver.sonatypeRepo("snapshots"))
+ else
+ Seq.empty
+}
diff --git a/src/sbt-test/scoverage/data-dir/src/main/scala/GoodCoverage.scala b/src/sbt-test/scoverage/data-dir/src/main/scala/GoodCoverage.scala
new file mode 100644
index 00000000..f4f3ecae
--- /dev/null
+++ b/src/sbt-test/scoverage/data-dir/src/main/scala/GoodCoverage.scala
@@ -0,0 +1,6 @@
+object GoodCoverage {
+
+ def sum(num1: Int, num2: Int) = {
+ num1 + num2
+ }
+}
\ No newline at end of file
diff --git a/src/sbt-test/scoverage/data-dir/src/test/scala/GoodCoverageSpec.scala b/src/sbt-test/scoverage/data-dir/src/test/scala/GoodCoverageSpec.scala
new file mode 100644
index 00000000..cbf6a70d
--- /dev/null
+++ b/src/sbt-test/scoverage/data-dir/src/test/scala/GoodCoverageSpec.scala
@@ -0,0 +1,13 @@
+import org.specs2.mutable._
+
+/**
+ * Created by tbarke001c on 7/8/14.
+ */
+class GoodCoverageSpec extends Specification {
+
+ "GoodCoverage" should {
+ "sum two numbers" in {
+ GoodCoverage.sum(1, 2) mustEqual 3
+ }
+ }
+}
diff --git a/src/sbt-test/scoverage/data-dir/test b/src/sbt-test/scoverage/data-dir/test
new file mode 100644
index 00000000..a211a6f7
--- /dev/null
+++ b/src/sbt-test/scoverage/data-dir/test
@@ -0,0 +1,7 @@
+# run scoverage
+> clean
+> coverage
+> test
+> coverageReport
+$ exists target/custom-test/scoverage-data
+$ exists target/custom-test/scoverage-report
\ No newline at end of file
diff --git a/src/sbt-test/scoverage/good-coverage/build.sbt b/src/sbt-test/scoverage/good-coverage/build.sbt
index c786340d..f24ad2a8 100644
--- a/src/sbt-test/scoverage/good-coverage/build.sbt
+++ b/src/sbt-test/scoverage/good-coverage/build.sbt
@@ -1,14 +1,21 @@
version := "0.1"
-scalaVersion := "2.12.8"
+scalaVersion := "2.13.6"
-libraryDependencies += "org.specs2" %% "specs2" % "2.5" % "test"
+libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
coverageMinimum := 80
+coverageMinimumStmtTotal := 100
+coverageMinimumBranchTotal := 100
+coverageMinimumStmtPerPackage := 100
+coverageMinimumBranchPerPackage := 100
+coverageMinimumStmtPerFile := 100
+coverageMinimumBranchPerFile := 100
coverageFailOnMinimum := true
resolvers ++= {
- if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots"))
+ if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT")))
+ Seq(Resolver.sonatypeRepo("snapshots"))
else Seq.empty
}
diff --git a/src/sbt-test/scoverage/good-coverage/project/plugins.sbt b/src/sbt-test/scoverage/good-coverage/project/plugins.sbt
index 8f2837b3..8d349239 100644
--- a/src/sbt-test/scoverage/good-coverage/project/plugins.sbt
+++ b/src/sbt-test/scoverage/good-coverage/project/plugins.sbt
@@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse(
"plugin.version",
throw new RuntimeException(
"""|The system property 'plugin.version' is not defined.
- |Specify this property using the scriptedLaunchOpts -D.""".stripMargin))
+ |Specify this property using the scriptedLaunchOpts -D.""".stripMargin
+ )
+)
addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion)
diff --git a/src/sbt-test/scoverage/good-coverage/src/main/scala/GoodCoverage.scala b/src/sbt-test/scoverage/good-coverage/src/main/scala/GoodCoverage.scala
index f4f3ecae..ac6582bb 100644
--- a/src/sbt-test/scoverage/good-coverage/src/main/scala/GoodCoverage.scala
+++ b/src/sbt-test/scoverage/good-coverage/src/main/scala/GoodCoverage.scala
@@ -1,6 +1,7 @@
object GoodCoverage {
def sum(num1: Int, num2: Int) = {
- num1 + num2
+ if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2
}
-}
\ No newline at end of file
+
+}
diff --git a/src/sbt-test/scoverage/good-coverage/src/main/scala/two/GoodCoverage.scala b/src/sbt-test/scoverage/good-coverage/src/main/scala/two/GoodCoverage.scala
new file mode 100644
index 00000000..587e11e1
--- /dev/null
+++ b/src/sbt-test/scoverage/good-coverage/src/main/scala/two/GoodCoverage.scala
@@ -0,0 +1,9 @@
+package two
+
+object GoodCoverage {
+
+ def sum(num1: Int, num2: Int) = {
+ if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2
+ }
+
+}
diff --git a/src/sbt-test/scoverage/good-coverage/src/test/scala/GoodCoverageSpec.scala b/src/sbt-test/scoverage/good-coverage/src/test/scala/GoodCoverageSpec.scala
index cbf6a70d..44eec1c9 100644
--- a/src/sbt-test/scoverage/good-coverage/src/test/scala/GoodCoverageSpec.scala
+++ b/src/sbt-test/scoverage/good-coverage/src/test/scala/GoodCoverageSpec.scala
@@ -1,13 +1,19 @@
-import org.specs2.mutable._
+import munit.FunSuite
-/**
- * Created by tbarke001c on 7/8/14.
- */
-class GoodCoverageSpec extends Specification {
+/** Created by tbarke001c on 7/8/14.
+ */
+class GoodCoverageSpec extends FunSuite {
- "GoodCoverage" should {
- "sum two numbers" in {
- GoodCoverage.sum(1, 2) mustEqual 3
- }
+ test("GoodCoverage should sum two numbers") {
+ assertEquals(GoodCoverage.sum(1, 2), 3)
+ assertEquals(GoodCoverage.sum(0, 3), 3)
+ assertEquals(GoodCoverage.sum(3, 0), 3)
}
+
+ test("two.GoodCoverage should sum two numbers") {
+ assertEquals(two.GoodCoverage.sum(1, 2), 3)
+ assertEquals(two.GoodCoverage.sum(0, 3), 3)
+ assertEquals(two.GoodCoverage.sum(3, 0), 3)
+ }
+
}
diff --git a/src/sbt-test/scoverage/preserve-set/build.sbt b/src/sbt-test/scoverage/preserve-set/build.sbt
index 8469864d..e4eb293e 100644
--- a/src/sbt-test/scoverage/preserve-set/build.sbt
+++ b/src/sbt-test/scoverage/preserve-set/build.sbt
@@ -2,36 +2,44 @@ import sbt.complete.DefaultParsers._
version := "0.1"
-scalaVersion := "2.12.8"
+scalaVersion := "2.13.6"
-crossScalaVersions := Seq("2.10.6", "2.12.8")
+crossScalaVersions := Seq("2.13.6")
-libraryDependencies += "org.specs2" %% "specs2" % "2.5" % "test"
+libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
-val checkScalaVersion = inputKey[Unit]("Input task to compare the value of scalaVersion setting with a given input.")
+val checkScalaVersion = inputKey[Unit](
+ "Input task to compare the value of scalaVersion setting with a given input."
+)
checkScalaVersion := {
val arg: String = (Space ~> StringBasic).parsed
- if (scalaVersion.value != arg) sys.error(s"scalaVersion [${scalaVersion.value}] not equal to expected [$arg]")
+ if (scalaVersion.value != arg)
+ sys.error(
+ s"scalaVersion [${scalaVersion.value}] not equal to expected [$arg]"
+ )
()
}
-val checkScoverageEnabled = inputKey[Unit]("Input task to compare the value of coverageEnabled setting with a given input.")
+val checkScoverageEnabled = inputKey[Unit](
+ "Input task to compare the value of coverageEnabled setting with a given input."
+)
checkScoverageEnabled := {
val arg: String = (Space ~> StringBasic).parsed
- if (coverageEnabled.value.toString != arg) sys.error(s"coverageEnabled [${coverageEnabled.value}] not equal to expected [$arg]")
+ if (coverageEnabled.value.toString != arg)
+ sys.error(
+ s"coverageEnabled [${coverageEnabled.value}] not equal to expected [$arg]"
+ )
()
}
-
resolvers ++= {
- if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots"))
+ if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT")))
+ Seq(Resolver.sonatypeRepo("snapshots"))
else Seq.empty
}
-// We force coverage to be always disabled for 2.10. This is not an uncommon real world scenario
coverageEnabled := {
CrossVersion.partialVersion(scalaVersion.value) match {
- case Some((2, 10)) => false
case _ => coverageEnabled.value
}
}
diff --git a/src/sbt-test/scoverage/preserve-set/project/plugins.sbt b/src/sbt-test/scoverage/preserve-set/project/plugins.sbt
index 8f2837b3..8d349239 100644
--- a/src/sbt-test/scoverage/preserve-set/project/plugins.sbt
+++ b/src/sbt-test/scoverage/preserve-set/project/plugins.sbt
@@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse(
"plugin.version",
throw new RuntimeException(
"""|The system property 'plugin.version' is not defined.
- |Specify this property using the scriptedLaunchOpts -D.""".stripMargin))
+ |Specify this property using the scriptedLaunchOpts -D.""".stripMargin
+ )
+)
addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion)
diff --git a/src/sbt-test/scoverage/preserve-set/src/test/scala/PreserveSetSpec.scala b/src/sbt-test/scoverage/preserve-set/src/test/scala/PreserveSetSpec.scala
index a7722e39..c4c26010 100644
--- a/src/sbt-test/scoverage/preserve-set/src/test/scala/PreserveSetSpec.scala
+++ b/src/sbt-test/scoverage/preserve-set/src/test/scala/PreserveSetSpec.scala
@@ -1,10 +1,8 @@
-import org.specs2.mutable._
+import munit.FunSuite
-class PreserveSetSpec extends Specification {
+class PreserveSetSpec extends FunSuite {
- "PreserveSet" should {
- "sum two numbers" in {
- PreserveSet.sum(1, 2) mustEqual 3
- }
+ test("PreserveSet should sum two numbers") {
+ assertEquals(PreserveSet.sum(1, 2), 3)
}
}
diff --git a/src/sbt-test/scoverage/preserve-set/test b/src/sbt-test/scoverage/preserve-set/test
index 2429a4dd..cc273221 100644
--- a/src/sbt-test/scoverage/preserve-set/test
+++ b/src/sbt-test/scoverage/preserve-set/test
@@ -1,19 +1,8 @@
# check scalaVersion setting
-> checkScalaVersion "2.12.8"
+> checkScalaVersion "2.13.6"
> checkScoverageEnabled "false"
> coverage
> checkScoverageEnabled "true"
> coverageOff
-> checkScalaVersion "2.12.8"
-> checkScoverageEnabled "false"
-# changs scala version
-> ++2.10.6
-> checkScalaVersion "2.10.6"
-> checkScoverageEnabled "false"
-> coverage
-> checkScalaVersion "2.10.6"
-# We want coverage to be false, as we set it in the build.sbt
-> checkScoverageEnabled "false"
-> coverageOff
-> checkScalaVersion "2.10.6"
+> checkScalaVersion "2.13.6"
> checkScoverageEnabled "false"
diff --git a/src/sbt-test/scoverage/scalac-plugin-version/build.sbt b/src/sbt-test/scoverage/scalac-plugin-version/build.sbt
index 1d927f49..df7f1c7c 100644
--- a/src/sbt-test/scoverage/scalac-plugin-version/build.sbt
+++ b/src/sbt-test/scoverage/scalac-plugin-version/build.sbt
@@ -4,13 +4,14 @@ lazy val root = (project in file(".")).settings(
TaskKey[Unit]("check") := {
assert(
- libraryDependencies.value
- .filter(module =>
- module.organization == "org.scoverage" && module.revision == "1.3.0")
- .size == 2)
+ libraryDependencies.value.count(module =>
+ module.organization == "org.scoverage" && module.revision == "1.3.0"
+ ) == 2
+ )
}
resolvers ++= {
- if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots"))
+ if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT")))
+ Seq(Resolver.sonatypeRepo("snapshots"))
else Seq.empty
}
diff --git a/src/sbt-test/scoverage/scalac-plugin-version/project/plugins.sbt b/src/sbt-test/scoverage/scalac-plugin-version/project/plugins.sbt
index 8f2837b3..8d349239 100644
--- a/src/sbt-test/scoverage/scalac-plugin-version/project/plugins.sbt
+++ b/src/sbt-test/scoverage/scalac-plugin-version/project/plugins.sbt
@@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse(
"plugin.version",
throw new RuntimeException(
"""|The system property 'plugin.version' is not defined.
- |Specify this property using the scriptedLaunchOpts -D.""".stripMargin))
+ |Specify this property using the scriptedLaunchOpts -D.""".stripMargin
+ )
+)
addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion)
diff --git a/src/sbt-test/scoverage/scalajs/build.sbt b/src/sbt-test/scoverage/scalajs/build.sbt
index 4f26c791..4406129c 100644
--- a/src/sbt-test/scoverage/scalajs/build.sbt
+++ b/src/sbt-test/scoverage/scalajs/build.sbt
@@ -3,19 +3,19 @@ import sbtcrossproject.CrossType
lazy val root = (project in file(".")).aggregate(crossJS, crossJVM)
-lazy val cross = CrossProject("sjstest", file("sjstest"))(JVMPlatform, JSPlatform)
- .crossType(CrossType.Full)
- .settings(
- scalaVersion := "2.12.8",
- libraryDependencies ++= Seq(
- "org.scalatest" %%% "scalatest" % "3.0.0" % "test"
+lazy val cross =
+ CrossProject("sjstest", file("sjstest"))(JVMPlatform, JSPlatform)
+ .crossType(CrossType.Full)
+ .settings(
+ scalaVersion := "2.13.6",
+ libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
)
- )
lazy val crossJS = cross.js
lazy val crossJVM = cross.jvm
-resolvers in ThisBuild ++= {
- if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots"))
+ThisBuild / resolvers ++= {
+ if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT")))
+ Seq(Resolver.sonatypeRepo("snapshots"))
else Seq.empty
}
diff --git a/src/sbt-test/scoverage/scalajs/project/plugins.sbt b/src/sbt-test/scoverage/scalajs/project/plugins.sbt
index 0b681ffe..3529aa34 100644
--- a/src/sbt-test/scoverage/scalajs/project/plugins.sbt
+++ b/src/sbt-test/scoverage/scalajs/project/plugins.sbt
@@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse(
"plugin.version",
throw new RuntimeException(
"""|The system property 'plugin.version' is not defined.
- |Specify this property using the scriptedLaunchOpts -D.""".stripMargin))
+ |Specify this property using the scriptedLaunchOpts -D.""".stripMargin
+ )
+)
addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion)
@@ -13,6 +15,6 @@ resolvers ++= {
Seq.empty
}
-addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.27")
+addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1")
-addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.0")
+addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")
diff --git a/src/sbt-test/scoverage/scalajs/sjstest/js/src/test/scala/JsTest.scala b/src/sbt-test/scoverage/scalajs/sjstest/js/src/test/scala/JsTest.scala
index 133c1a36..c7d3eed4 100644
--- a/src/sbt-test/scoverage/scalajs/sjstest/js/src/test/scala/JsTest.scala
+++ b/src/sbt-test/scoverage/scalajs/sjstest/js/src/test/scala/JsTest.scala
@@ -1,10 +1,9 @@
-import org.scalatest.{FlatSpec, Matchers}
+import munit.FunSuite
-class JsTest extends FlatSpec with Matchers {
+class JsTest extends FunSuite {
- "JS UnderTest" should "work on JS" in {
- UnderTest.jsMethod shouldBe "js"
+ test("JS UnderTest should work on JS") {
+ assertEquals(UnderTest.jsMethod, "js")
}
}
-
diff --git a/src/sbt-test/scoverage/scalajs/sjstest/jvm/src/test/scala/JvmTest.scala b/src/sbt-test/scoverage/scalajs/sjstest/jvm/src/test/scala/JvmTest.scala
index 80739a94..b5f3ed9e 100644
--- a/src/sbt-test/scoverage/scalajs/sjstest/jvm/src/test/scala/JvmTest.scala
+++ b/src/sbt-test/scoverage/scalajs/sjstest/jvm/src/test/scala/JvmTest.scala
@@ -1,10 +1,9 @@
-import org.scalatest.{FlatSpec, Matchers}
+import munit.FunSuite
-class JvmTest extends FlatSpec with Matchers {
+class JvmTest extends FunSuite {
- "JVM UnderTest" should "work on JVM" in {
- UnderTest.jvmMethod shouldBe "jvm"
+ test("JVM UnderTest work on JVM") {
+ assertEquals(UnderTest.jvmMethod, "jvm")
}
}
-
diff --git a/src/sbt-test/scoverage/scalajs/sjstest/shared/src/main/scala/UnderTest.scala b/src/sbt-test/scoverage/scalajs/sjstest/shared/src/main/scala/UnderTest.scala
index 66a31844..9b279395 100644
--- a/src/sbt-test/scoverage/scalajs/sjstest/shared/src/main/scala/UnderTest.scala
+++ b/src/sbt-test/scoverage/scalajs/sjstest/shared/src/main/scala/UnderTest.scala
@@ -1,4 +1,3 @@
-
object UnderTest {
def onJsAndJvm: String = "js and jvm"
diff --git a/src/sbt-test/scoverage/scalajs/sjstest/shared/src/test/scala/SharedTest.scala b/src/sbt-test/scoverage/scalajs/sjstest/shared/src/test/scala/SharedTest.scala
index fecebac8..bbc145ae 100644
--- a/src/sbt-test/scoverage/scalajs/sjstest/shared/src/test/scala/SharedTest.scala
+++ b/src/sbt-test/scoverage/scalajs/sjstest/shared/src/test/scala/SharedTest.scala
@@ -1,9 +1,9 @@
-import org.scalatest.{FlatSpec, Matchers}
+import munit.FunSuite
-class SharedTest extends FlatSpec with Matchers {
+class SharedTest extends FunSuite {
- "Shared UnderTest" should "return where it works" in {
- UnderTest.onJsAndJvm shouldBe "js and jvm"
+ test("Shared UnderTest return where it works") {
+ assertEquals(UnderTest.onJsAndJvm, "js and jvm")
}
}
diff --git a/src/sbt-test/scoverage/scalajs/test b/src/sbt-test/scoverage/scalajs/test
index 6e6be49f..f6c10798 100644
--- a/src/sbt-test/scoverage/scalajs/test
+++ b/src/sbt-test/scoverage/scalajs/test
@@ -3,9 +3,9 @@
> coverage
> test
# There should be scoverage-data directory
-$ exists sjstest/js/target/scala-2.12/scoverage-data
-$ exists sjstest/jvm/target/scala-2.12/scoverage-data
+$ exists sjstest/js/target/scala-2.13/scoverage-data
+$ exists sjstest/jvm/target/scala-2.13/scoverage-data
> coverageReport
# There should be scoverage-report directory
-$ exists sjstest/js/target/scala-2.12/scoverage-report
-$ exists sjstest/jvm/target/scala-2.12/scoverage-report
+$ exists sjstest/js/target/scala-2.13/scoverage-report
+$ exists sjstest/jvm/target/scala-2.13/scoverage-report
diff --git a/version.sbt b/version.sbt
deleted file mode 100644
index e5cd55e1..00000000
--- a/version.sbt
+++ /dev/null
@@ -1 +0,0 @@
-version in ThisBuild := "1.6.2-SNAPSHOT"