-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose reportDir property in KoverHtmlReport interface
if there is a need to analyze the HTML report after it is generated, or if you need to improve the report (for example, by editing CSS styles), you need to know the directory of each report. Currently, it is not possible to easily link a specific report generation task and a directory. Resolves #590 PR #591
- Loading branch information
Showing
4 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...ionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/TaskInterfacesTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright 2017-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
package kotlinx.kover.gradle.plugin.test.functional.cases | ||
|
||
import kotlinx.kover.gradle.plugin.test.functional.framework.runner.generateBuild | ||
import kotlinx.kover.gradle.plugin.test.functional.framework.runner.runWithParams | ||
import org.junit.jupiter.api.Test | ||
import kotlin.test.assertTrue | ||
|
||
internal class TaskInterfacesTests { | ||
|
||
@Test | ||
fun testDefaultHtmlDir() { | ||
val build = generateBuild { dir -> | ||
dir.resolve("settings.gradle.kts").createNewFile() | ||
|
||
dir.resolve("build.gradle.kts").writeText( | ||
""" | ||
import kotlinx.kover.gradle.plugin.dsl.tasks.KoverHtmlReport | ||
plugins { | ||
kotlin("jvm") version "1.9.22" | ||
id("org.jetbrains.kotlinx.kover") | ||
} | ||
tasks.register("checkDir") { | ||
doFirst { | ||
val task = tasks.withType<KoverHtmlReport>().matching { it.name == "koverHtmlReport" }.first() | ||
if (task.reportDir.get().asFile != layout.buildDirectory.dir("reports/kover/html").get().asFile) { | ||
throw Exception("Default directory differ, expect ${'$'}{layout.buildDirectory.dir("reports/kover/html").get().asFile} actual ${'$'}{task.reportDir.get().asFile}") | ||
} | ||
} | ||
} | ||
""".trimIndent() | ||
) | ||
}.generate() | ||
|
||
val result = build.runWithParams("checkDir") | ||
assertTrue(result.isSuccessful) | ||
} | ||
|
||
@Test | ||
fun testCustomHtmlDir() { | ||
val build = generateBuild { dir -> | ||
dir.resolve("settings.gradle.kts").createNewFile() | ||
|
||
dir.resolve("build.gradle.kts").writeText( | ||
""" | ||
import kotlinx.kover.gradle.plugin.dsl.tasks.KoverHtmlReport | ||
plugins { | ||
kotlin("jvm") version "1.9.22" | ||
id("org.jetbrains.kotlinx.kover") | ||
} | ||
kover { | ||
reports { | ||
total { | ||
html { | ||
htmlDir.set(layout.buildDirectory.dir("customHtmlReport")) | ||
} | ||
} | ||
} | ||
} | ||
tasks.register("checkDir") { | ||
doFirst { | ||
val task = tasks.withType<KoverHtmlReport>().matching { it.name == "koverHtmlReport" }.first() | ||
if (task.reportDir.get().asFile != layout.buildDirectory.dir("customHtmlReport").get().asFile) { | ||
throw Exception("Custom directory differ, expect ${'$'}{layout.buildDirectory.dir("customHtmlReport").get().asFile} actual ${'$'}{task.reportDir.get().asFile}") | ||
} | ||
} | ||
} | ||
""".trimIndent() | ||
) | ||
}.generate() | ||
|
||
val result = build.runWithParams("checkDir") | ||
assertTrue(result.isSuccessful) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters