mill.contrib.scoverage

Members list

Type members

Classlikes

Adds tasks to a mill.scalalib.ScalaModule to create test coverage reports.

Adds tasks to a mill.scalalib.ScalaModule to create test coverage reports.

This module allows you to generate code coverage reports for Scala projects with Scoverage via the scoverage compiler plugin.

To declare a module for which you want to generate coverage reports you can extend the mill.contrib.scoverage.ScoverageModule trait when defining your Module. Additionally, you must define a submodule that extends the ScoverageTests trait that belongs to your instance of ScoverageModule.

//| mvnDeps: ["com.lihaoyi::mill-contrib-buildinfo:$MILL_VERSION"]

import mill.contrib.scoverage.ScoverageModule

Object foo extends ScoverageModule  {
 def scalaVersion = "2.13.15"
 def scoverageVersion = "2.1.1"

 object test extends ScoverageTests with TestModule.ScalaTest {
   def scalaTestVersion = "3.2.19"
 }
}

In addition to the normal tasks available to your Scala module, Scoverage Modules introduce a few new tasks and changes the behavior of an existing one.

  • mill foo.scoverage.compile # compiles your module with test instrumentation # (you don't have to run this manually, running the test task will force its invocation)

  • mill foo.test # tests your project and collects metrics on code coverage

  • mill foo.scoverage.htmlReport # uses the metrics collected by a previous test run to generate a coverage report in html format

  • mill foo.scoverage.xmlReport # uses the metrics collected by a previous test run to generate a coverage report in xml format

The measurement data by default is available at out/foo/scoverage/dataDir.dest/, the html report is saved in out/foo/scoverage/htmlReport.dest/, and the xml report is saved in out/foo/scoverage/xmlReport.dest/.

Attributes

Source
ScoverageModule.scala
Supertypes
trait ScalaModule
trait JavaModule
trait RunModule
trait RunModuleApi
trait BspModule
trait BspModuleApi
trait Module
trait ModuleApi
trait Wrapper
class BaseClass
trait Cacher
trait Cacher
class Object
trait Matchable
class Any
Show all
Known subtypes
Self type
trait ScoverageReport extends Module

Allows the aggregation of coverage reports across multi-module projects.

Allows the aggregation of coverage reports across multi-module projects.

Once tests have been run across all modules, this collects reports from all modules that extend mill.contrib.scoverage.ScoverageModule. Simply define a module that extends mill.contrib.scoverage.ScoverageReport and call one of the available "report all" functions.

For example, define the following scoverage module and use the relevant reporting option to generate a report:

object scoverage extends ScoverageReport {
 override def scalaVersion     = "<scala-version>"
 override def scoverageVersion = "<scoverage-version>"
}
  • mill __.test # run tests for all modules
  • mill scoverage.htmlReportAll # generates report in html format for all modules
  • mill scoverage.xmlReportAll # generates report in xml format for all modules
  • mill scoverage.xmlCoberturaReportAll # generates report in Cobertura's xml format for all modules
  • mill scoverage.consoleReportAll # reports to the console for all modules

The aggregated report will be available at either out/scoverage/htmlReportAll.dest/ for html reports or out/scoverage/xmlReportAll.dest/ for xml reports.

Attributes

Source
ScoverageReport.scala
Supertypes
trait Module
trait ModuleApi
trait Wrapper
class BaseClass
trait Cacher
trait Cacher
class Object
trait Matchable
class Any
Show all
Self type

Attributes

Companion
object
Source
ScoverageReportWorker.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Source
ScoverageReportWorker.scala
Supertypes
class RootModule0
trait Module
trait ModuleApi
trait Wrapper
class BaseClass
trait Cacher
trait Cacher
class Object
trait Matchable
class Any
Show all
Self type