Skip to content

Commit 850122f

Browse files
jqnogslowikowski
authored andcommitted
#61 Document additionalForkedProjectProperties configuration parameter
1 parent 50718fa commit 850122f

File tree

1 file changed

+55
-2
lines changed

1 file changed

+55
-2
lines changed

README.md

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ Read [SBT SCoverage Plugin documentation](https://github.com/scoverage/sbt-scove
286286
<goals>
287287
<goal>check</goal> <!-- or integration-check -->
288288
</goals>
289-
<phase>prepare-package</phase> <!-- or any other phase -->
290289
</execution>
291290
</executions>
292291
</plugin>
@@ -295,6 +294,8 @@ Read [SBT SCoverage Plugin documentation](https://github.com/scoverage/sbt-scove
295294
</project>
296295
```
297296

297+
Run `mvn scoverage:check` to perform the check. See below if you want to use `mvn verify` to perform the check.
298+
298299
Read [SBT SCoverage Plugin documentation](https://github.com/scoverage/sbt-scoverage#minimum-coverage) for more information.
299300

300301

@@ -317,7 +318,6 @@ Read [SBT SCoverage Plugin documentation](https://github.com/scoverage/sbt-scove
317318
<goals>
318319
<goal>check</goal> <!-- or integration-check -->
319320
</goals>
320-
<phase>prepare-package</phase> <!-- or any other phase -->
321321
</execution>
322322
</executions>
323323
</plugin>
@@ -343,6 +343,59 @@ Read [SBT SCoverage Plugin documentation](https://github.com/scoverage/sbt-scove
343343
</project>
344344
```
345345

346+
Run `mvn scoverage:check` to perform the check and `mvn scoverage:report` to generate the report.
347+
348+
349+
##### Checking minimum test coverage level automatically
350+
351+
If you want `mvn verify` and `mvn install` to check the coverage level, you have change your POM so that SCoverage takes over running all the tests.
352+
353+
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. This causes the tests to be run twice: once with the original classes and once through SCoverage with the instrumented ones. To make sure the tests run only once, you have to configure your pom like this:
354+
355+
```xml
356+
<properties>
357+
<skipTests>true</skipTests> <!-- disable surefire tests -->
358+
</properties>
359+
360+
...
361+
362+
<project>
363+
<build>
364+
<plugins>
365+
<plugin>
366+
<groupId>org.scoverage</groupId>
367+
<artifactId>scoverage-maven-plugin</artifactId>
368+
<version>${scoverage.plugin.version}</version>
369+
<configuration>
370+
<minimumCoverage>80</minimumCoverage>
371+
<failOnMinimumCoverage>true</failOnMinimumCoverage>
372+
373+
<!-- enable surefire tests in SCoverage -->
374+
<additionalForkedProjectProperties>skipTests=false</additionalForkedProjectProperties>
375+
</configuration>
376+
<executions>
377+
<execution>
378+
<goals>
379+
<goal>check</goal> <!-- or integration-check -->
380+
</goals>
381+
<phase>prepare-package</phase> <!-- or any other phase -->
382+
</execution>
383+
</executions>
384+
</plugin>
385+
</plugins>
386+
</build>
387+
</project>
388+
```
389+
390+
Run `mvn clean verify` or `mvn clean install` to run the tests with coverage and all other static analysis you have configured.
391+
392+
If you want to set multiple properties from within `<additionalForkedProjectProperties>`, for instance because you want to disable other plugins from running twice, you can separate them with a semicolon:
393+
394+
`<additionalForkedProjectProperties>skipTests=false;skip.scalafmt=false</additionalForkedProjectProperties>`
395+
396+
397+
## Examples
398+
346399
There are many [example projects](https://github.com/scoverage/scoverage-maven-samples/tree/scoverage-maven-samples-1.3.0/).
347400
Go to one of them and run `mvn site`.
348401

0 commit comments

Comments
 (0)