在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):scoverage/scoverage-maven-plugin开源软件地址(OpenSource Url):https://github.com/scoverage/scoverage-maven-plugin开源编程语言(OpenSource Language):Java 99.1%开源软件介绍(OpenSource Introduction):scoverage-maven-pluginscoverage-maven-plugin is a plugin for Maven that integrates the scoverage code coverage library. Find out more about scoverage. How to usemostly used mojos:
additional, sometimes useful, mojos:
internal mojos:
Maven generated plugin documentation:
Prerequisities / limitationsPlugin is compatible with two Maven Scala compiler plugins:
Scoverage Maven plugin versionThis can be set as project property. <project>
<properties>
<scoverage.plugin.version>1.4.11</scoverage.plugin.version>
</properties>
</project> Scala version configurationPlugin supports Scala 2.10.x, 2.11.x, 2.12.x and 2.13.x versions by automatically loading and configuring scalac-scoverage-plugin_2.10, scalac-scoverage-plugin_2.11, scalac-scoverage-plugin_2.12 or scalac-scoverage-plugin_2.13 Scalac SCoverage Plugin artifact. For this to work Scala version has to be set. It can be done by defining <project>
<properties>
<scala.version>2.13.8</scala.version>
</properties>
</project> or <project>
<build>
<plugins>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<configuration>
<scalaVersion>2.13.8</scalaVersion>
<!-- other parameters -->
</configuration>
</plugin>
</plugins>
</build>
</project> The first method is better because once the property is defined it's value can be used in other places of the build file. For example in <project>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
</dependencies>
</project> Scalac SCoverage plugin version configurationMaven SCoverage plugin uses by default the latest version of the scalac-scoverage-plugin available on its release day.
If newer, better version of scalac-scoverage-plugin is available, it can be used instead.
It can be configured by defining <project>
<properties>
<scoverage.scalacPluginVersion>1.4.11</scoverage.scalacPluginVersion>
</properties>
</project> or <project>
<build>
<plugins>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<configuration>
<scalacPluginVersion>1.4.11</scalacPluginVersion>
<!-- other parameters -->
</configuration>
</plugin>
</plugins>
</build>
</project> Integration tests coverage check and reports
Aggregated reports for multi-module projectsThere is no separate mojo for aggregated reports, there is It can be configured by defining <project>
<properties>
<scoverage.aggregate>true</scoverage.aggregate>
</properties>
</project> in <project>
<build>
<plugins>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<configuration>
<aggregate>true</aggregate>
</configuration>
</plugin>
</plugins>
</build>
</project> or in <project>
<reporting>
<plugins>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<configuration>
<aggregate>true</aggregate>
</configuration>
</plugin>
</plugins>
</reporting>
</project> Since version To generate only aggregated SCoverage report, set It can be configured by defining <project>
<properties>
<scoverage.aggregateOnly>true</scoverage.aggregateOnly>
</properties>
</project> in <project>
<build>
<plugins>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<configuration>
<aggregateOnly>true</aggregateOnly>
</configuration>
</plugin>
</plugins>
</build>
</project> or in <project>
<reporting>
<plugins>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<configuration>
<aggregateOnly>true</aggregateOnly>
</configuration>
</plugin>
</plugins>
</reporting>
</project> Adding SCoverage report to siteAdd plugin to reporting section of your project and configure it to generate one of reporting mojos. By default Maven executes all plugin's reporting mojos, but SCoverage plugin has three such mojos and it does not make sense, to execute them all because every executed report will overwrite the previous one. Configure one of them depending on your case. <project>
<reporting>
<plugins>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<reportSets>
<reportSet>
<reports>
<report>report</report>
<!-- or <report>integration-report</report> -->
<!-- or <report>report-only</report> -->
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
</project> Which reporting mojo should be selected:
Customizing code instrumentationIf you want to customize plugin's configuration parameters used by compilation supporting part of the plugin, do it in 'plugins' or 'pluginManagement' section: <project>
<build>
<plugins>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<configuration>
<highlighting>true</highlighting>
<!-- example configuration for Play! Framework 2.x project -->
<excludedPackages>views.html.*</excludedPackages>
<excludedFiles>.*?routes_(routing|reverseRouting)</excludedFiles>
</configuration>
</plugin>
</plugins>
</build>
</project> Read SBT SCoverage Plugin documentation for more information about highlighting and excludedPackages. Checking minimum test coverage level<project>
<build>
<plugins>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<configuration>
<minimumCoverage>80</minimumCoverage>
<failOnMinimumCoverage>true</failOnMinimumCoverage>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal> <!-- or integration-check -->
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> Run Read SBT SCoverage Plugin documentation for more information. Checking minimum test coverage level AND adding report to site<project>
<build>
<plugins>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<configuration>
<minimumCoverage>80</minimumCoverage>
<failOnMinimumCoverage>true</failOnMinimumCoverage>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal> <!-- or integration-check -->
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<reportSets>
<reportSet>
<reports>
<report>report-only</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
</project> Run Checking minimum test coverage level automaticallyIf you want The reason for this is that SCoverage instruments classes during compilation and writes them to disk. We don't want to accidentally deploy these instrumented classes, so SCoverage keeps them separate. SCoverage does this by forking the current Maven build and running it again, while performing instrumentation. In a normal setup this causes the tests to be run twice: once in the outer run with the original classes and once in the SCoverage-forked run with the instrumented classes. Since version This example shows the required configuration: <project>
<properties>
<skipTests>true</skipTests> <!-- disable surefire and failsafe tests -->
</properties>
...
<build>
<plugins>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<configuration>
<minimumCoverage>80</minimumCoverage>
<failOnMinimumCoverage>true</failOnMinimumCoverage>
<!-- enable surefire and failsafe tests in SCoverage -->
<additionalForkedProjectProperties>skipTests=false</additionalForkedProjectProperties>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal> <!-- or integration-check -->
</goals>
<phase>prepare-package</phase> <!-- or any other phase -->
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> Run If you want to set multiple properties from within
ExamplesThere are many example projects.
Go to one of them and run License
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论