-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathREADME.md
160 lines (114 loc) · 5.67 KB
/
README.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Kover
[](https://kotlinlang.org/docs/components-stability.html)
[](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
[](https://www.apache.org/licenses/LICENSE-2.0)
Kover is a set of solutions for collecting test coverage of Kotlin code compiled for JVM and Android platforms.
Kover Toolset:
- [Kover Gradle Plugin](#kover-gradle-plugin)
- [Kover Maven Plugin](#kover-maven-plugin)
- [Kover CLI](#kover-cli)
- [Kover offline instrumentation](#kover-offline-instrumentation)
- [Kover JVM agent](#kover-jvm-agent)
- [Kover features artifact](#kover-features-artifact)
## Kover Gradle Plugin
For full information about latest stable release of Kover Gradle Plugin, please refer to the [documentation](https://kotlin.github.io/kotlinx-kover/gradle-plugin).
### Features
* Collection of code coverage through `JVM` tests (JS and native targets are not supported yet).
* Generating `HTML` and `XML` reports.
* Support for `Kotlin JVM`, `Kotlin Multiplatform` projects.
* Support for `Kotlin Android` projects with build variants (instrumentation tests executing on the Android device are not supported yet).
* Support mixed `Kotlin` and `Java` sources
* Verification rules with bounds in the Gradle plugin to keep track of coverage.
* Using JaCoCo library in Gradle plugin as an alternative for coverage measuring and report generation.
The recommended way of applying Kover is with the
[plugins DSL](https://docs.gradle.org/current/userguide/plugins.html#sec:plugins_block).
Minimum supported version of `Gradle` is `6.8`.
Add the following to your top-level build file:
<details open>
<summary>Kotlin</summary>
```kotlin
plugins {
id("org.jetbrains.kotlinx.kover") version "0.8.3"
}
```
</details>
<details>
<summary>Groovy</summary>
```groovy
plugins {
id 'org.jetbrains.kotlinx.kover' version '0.8.3'
}
```
</details>
After you applied Kover Gradle plugin, Kover tasks will be created for generating reports and verification.
E.g. to generate HTML report run `./gradlew koverHtmlReport` - this will automatically start code compilation, execution of instrumented tests, and an HTML report will be generated with measurement results in the build folder.
It is also important that after applying Kover Gradle plugin, during the running tests, the classes are modified (instrumented) when loaded into the JVM which may lead to some performance degradation, or affect concurrent tests.
### Legacy Plugin Application
[Legacy method](https://docs.gradle.org/current/userguide/plugins.html#sec:old_plugin_application) of applying plugins
can be used if you cannot use the plugins DSL for some reason.
<details open>
<summary>Kotlin</summary>
```kotlin
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.jetbrains.kotlinx:kover-gradle-plugin:0.8.3")
}
}
apply(plugin = "org.jetbrains.kotlinx.kover")
```
</details>
<details>
<summary>Groovy</summary>
```groovy
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.jetbrains.kotlinx:kover-gradle-plugin:0.8.3'
}
}
apply plugin: 'org.jetbrains.kotlinx.kover'
```
</details>
### To create report combining coverage info from different Gradle projects
You have to add dependency on the project, in which the report task will be run
```groovy
dependencies {
kover(project(":another:project"))
}
```
in this case report will be generated for current project joined with `:another:project` project.
**More examples of Gradle plugin applying can be found in [example folder](kover-gradle-plugin/examples)**
## Kover Aggregated Plugin
Kover Aggregated Plugin as a prototype of Gradle Settings plugin, created to simplify the setup of multi-project builds.
It is in its infancy, it is recommended to use it only for test or pet projects.
Refer to the [documentation](https://kotlin.github.io/kotlinx-kover/gradle-plugin/aggregated.html) for details.
## Kover Maven Plugin
The Kover Maven Plugin can be applied by specifying build plugin
```xml
<plugin>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kover-maven-plugin</artifactId>
<version>0.8.3</version>
</plugin>
```
The list of Kover goals is specified in [this document section](https://kotlin.github.io/kotlinx-kover/maven-plugin#goals).
For full information about latest stable release of Kover Gradle Plugin, please refer to the [documentation](https://kotlin.github.io/kotlinx-kover/maven-plugin).
## Kover CLI
Standalone JVM application used for offline instrumentation and generation of human-readable reports.
[Documentation of the Kover CLI](https://kotlin.github.io/kotlinx-kover/cli).
## Kover offline instrumentation
Offline instrumentation is the modification of class-files stored on disk to measure their coverage.
The ways of offline instrumentation and running of the instrumented applications are described in the [documentation](https://kotlin.github.io/kotlinx-kover/offline-instrumentation).
## Kover JVM agent
JVM agent is a jar file that modifies the bytecode of loaded into the JVM classes in order to measure coverage.
[Documentations](https://kotlin.github.io/kotlinx-kover/jvm-agent).
## Kover features artifact
A JVM dependency that allows to programmatically instrument class-files on a disk.
[Documentation of Kover features artifact](https://kotlin.github.io/kotlinx-kover/offline-instrumentation/#instrumentation-by-kover-features)
## Building locally and Contributing
See [Contributing Guidelines](https://github.com/Kotlin/kotlinx-kover/tree/main/CONTRIBUTING.md).