@@ -6,90 +6,61 @@ A plugin to enable the use of Scoverage in a gradle Scala project.
6
6
7
7
Getting started
8
8
---------------
9
- http://plugins.gradle.org/plugin/org.scoverage
10
-
11
- This creates an additional task ` testScoverage ` which will run tests against instrumented code.
12
-
13
- A further task ` reportScoverage ` produces XML and HTML reports for analysing test code coverage.
14
-
15
- You can configure the version of Scoverage that will be used. This plugin should be compatible with all 1+ versions.
16
9
17
- ``` groovy
18
- scoverage {
19
- scoverageVersion = "1.3.1"
20
- scoverageScalaVersion = "2.12" // will be overridden by the 'scala-library' version (if configured)
21
- }
22
- ```
23
-
24
- Then launch command :
25
- ` gradle reportScoverage ` or ` gradle checkScoverage `
10
+ http://plugins.gradle.org/plugin/org.scoverage
26
11
27
12
Available tasks
28
13
---------------
29
14
30
- * testScoverage - Executes all tests and creates Scoverage XML report with information about code coverage
31
- * reportScoverage - Generates reports (see below).
32
- * aggregateScoverage - Aggregates reports from multiple sub-projects (see below).
33
- * checkScoverage - See below.
34
- * compileScoverageScala - Instruments code without running tests.
15
+ 1 . ` reportScoverage ` : Produces XML and HTML reports for analysing test code coverage.
35
16
36
- ReportScoverage
37
- ---------------
17
+ 2 . ` aggregateScoverage ` : An experimental support for aggregating coverage statistics in composite builds.
38
18
39
- You can configure output generated by ` gradle reportScoverage ` using flags:
19
+ When applied on a project with sub-projects, the plugin will create the aggregation task ` aggregateScoverage ` , which
20
+ will first generate reports for each project individually (including the parent project), and will then generate an
21
+ aggregated result based on these reports.
40
22
41
- | Flag name | Default value | Description |
42
- | ------------------------| ---------------| -------------------------------------------------|
43
- | coverageOutputCobertura | true | Enables/disables cobertura.xml file generation. |
44
- | coverageOutputXML | true | Enables/disables scoverage XML output. |
45
- | coverageOutputHTML | true | Enables/disables scoverage HTML output. |
46
- | coverageDebug | false | Enables/disables scoverage debug output. |
23
+ The aggregated report will override the parent-project specific report (` parent-project/build/reports/scoverage ` ).
47
24
48
- Aggregating Reports
49
- -------------------
25
+ One can still use ` reportScoverage ` in order to generate a report without aggregation.
50
26
27
+ 3 . ` checkScoverage ` : Validates coverage according status according the generated reports (aggregated or not).
51
28
52
- There is now experimental support for aggregating coverage statistics in composite builds.
29
+ ` gradle checkScoverage ` will automatically invoke ` reportScoverage ` but it won't generate aggregated reports.
30
+ In order to check coverage of aggregated reports one should use ` gradle checkScoverage aggregateScoverage ` .
31
+
32
+ Configuration
33
+ ---------------
53
34
54
- When applied on a project with sub-projects, the plugin will create the aggregation task ` aggregateScoverage ` , which
55
- will first generate reports for each project individually (including the parent project), and will then generate an
56
- aggregated result based on these reports.
35
+ The plugin exposes multiple options that can be configured by setting them in an ` scoverage ` block within the project's
36
+ build script. These options are as follows:
57
37
58
- The aggregated report will override the parent-project specific report ( ` parent-project/build/reports/scoverage ` ).
38
+ You can configure the version of Scoverage that will be used. This plugin should
59
39
60
- One can still use ` reportScoverage ` in order to generate a report without aggregation.
40
+ * ` scoverageVersion = <String> ` (default ` "1.3.1" ` ): The version of the scoverage scalac plugin. This (gradle) plugin
41
+ should be compatible with all 1+ versions.
61
42
62
- Aggregation uses same flags as reporting for enabling/disabling different output types.
43
+ * ` scoverageScalaVersion = <String> ` (default ` "2.12" ` ): The scala version of the scoverage scalac plugin. This will
44
+ be overridden by the version of the ` scala-library ` compile dependency (if the dependency is configured).
45
+
46
+ * ` coverageOutputCobertura = <boolean> ` (default ` true ` ): Enables/disables cobertura.xml file generation (for both aggregated and non-aggregated reports).
63
47
64
- CheckScoverage
65
- --------------
48
+ * ` coverageOutputXML = <boolean> ` (default ` true ` ): Enables/disables scoverage XML output (for both aggregated and non-aggregated reports).
66
49
67
- The ` checkScoverage ` task validates coverage status according the generated reports.
50
+ * ` coverageOutputHTML = <boolean> ` (default ` true ` ): Enables/disables scoverage HTML output (for both aggregated and non-aggregated reports) .
68
51
69
- ` gradle checkScoverage ` will automatically generate reports via ` reportScoverage ` but it won't generate aggregated reports.
70
- In order to check coverage of aggregated reports one should use ` gradle checkScoverage aggregateScoverage ` .
52
+ * ` coverageDebug = <boolean> ` (default ` false ` ): Enables/disables scoverage debug output (for both aggregated and non-aggregated reports).
71
53
72
- By default, when you launch ` gradle checkScoverage ` build fail if only 75% of statements in project is covered by tests.
54
+ * ` minimumRate = <double> ` (default ` 0.75 ` ): The minimum amount of coverage in decimal proportion (` 1.0 ` == 100%)
55
+ required for the validation to pass (otherwise ` checkScoverage ` will fail the build).
73
56
74
- To configure it as you want, add this configuration :
75
- ```
76
- checkScoverage {
77
- minimumRate = 0.5
78
- }
79
- ```
57
+ * ` coverageType = <"Statement" | "Branch" | "Line"> ` (default ` "Statement" ` ): The type of coverage validated by the
58
+ ` checkScoverage ` task. For more information on the different types, please refer to the documentation of the scalac
59
+ plugin (https://github.com/scoverage/scalac-scoverage-plugin ).
80
60
81
- You can also modify type of value to check from ` Statement ` s to ` Line ` s or ` Branch ` es:
61
+ * ` runNormalCompilation = <boolean> ` (default ` true ` ): Determines whether both normal scalac compilation (` compileScala ` )
62
+ and compilation with scoverage (` compileScoverageScala ` ) should be executed, or if only the scoverage compilation should.
63
+ It may be helpful to turn this off so that only the scoverage instrumented classes -- which are not intended for release
64
+ -- will be created, thus reducing the build time.
82
65
83
- ```
84
- checkScoverage {
85
- coverageType = 'Line'
86
- minimumRate = 0.5
87
- }
88
- ```
89
66
90
- ```
91
- checkScoverage {
92
- coverageType = 'Branch'
93
- minimumRate = 0.5
94
- }
95
- ```
0 commit comments