Skip to content

Commit 26551b9

Browse files
author
Mathias Düsterhöft
committed
Record test coverage in gradle testkit tests
1 parent acfb250 commit 26551b9

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,10 @@ allprojects {
5656
apply(plugin = "jacoco")
5757
apply(plugin = "maven-publish")
5858
apply(plugin = "org.jmailen.kotlinter")
59-
6059
}
6160
}
6261

6362

64-
6563
subprojects {
6664

6765
val jacksonVersion by extra { "2.9.5" }

restdocs-api-spec-gradle-plugin/build.gradle.kts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ gradlePlugin {
2626
val jacksonVersion: String by extra
2727
val junitVersion: String by extra
2828

29+
val jacocoRuntime by configurations.creating
30+
2931
dependencies {
3032
compileOnly(gradleKotlinDsl())
3133

@@ -44,4 +46,20 @@ dependencies {
4446
testImplementation("com.jayway.jsonpath:json-path:2.4.0")
4547

4648
testCompile(gradleTestKit())
49+
50+
jacocoRuntime("org.jacoco:org.jacoco.agent:0.8.2:runtime")
51+
}
52+
53+
val createTestKitFiles by tasks.creating {
54+
val outputDir = project.file("$buildDir/testkitFiles")
55+
56+
inputs.files(jacocoRuntime)
57+
outputs.dir(outputDir)
58+
59+
doLast {
60+
outputDir.mkdirs()
61+
file("$outputDir/testkit-gradle.properties").writeText("org.gradle.jvmargs=-javaagent:${jacocoRuntime.asPath}=destfile=$buildDir/jacoco/test.exec")
62+
}
4763
}
64+
65+
tasks["test"].dependsOn(createTestKitFiles)

0 commit comments

Comments
 (0)