-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to generate reports even if there are no tests in the p…
- Loading branch information
Showing
15 changed files
with
164 additions
and
36 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
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
52 changes: 52 additions & 0 deletions
52
...tionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/NoTestReportsTests.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,52 @@ | ||
package kotlinx.kover.gradle.plugin.test.functional.cases | ||
|
||
import kotlinx.kover.gradle.plugin.test.functional.framework.checker.createCheckerContext | ||
import kotlinx.kover.gradle.plugin.test.functional.framework.checker.defaultXmlReport | ||
import kotlinx.kover.gradle.plugin.test.functional.framework.runner.BuildSource | ||
import kotlinx.kover.gradle.plugin.test.functional.framework.runner.buildFromTemplate | ||
import kotlinx.kover.gradle.plugin.test.functional.framework.runner.runWithParams | ||
import org.junit.jupiter.api.Test | ||
import kotlin.test.assertContains | ||
import kotlin.test.assertFalse | ||
import kotlin.test.assertTrue | ||
|
||
class NoTestReportsTests { | ||
@Test | ||
fun testNoTestsJvm() { | ||
val build = buildFromTemplate("no-tests-jvm") | ||
check(build) | ||
checkWithVerify(build) | ||
} | ||
|
||
@Test | ||
fun testNoTestsMpp() { | ||
val build = buildFromTemplate("no-tests-mpp") | ||
check(build) | ||
checkWithVerify(build) | ||
} | ||
|
||
private fun check(buildSource: BuildSource) { | ||
val build = buildSource.generate() | ||
val buildResult = build.runWithParams("koverXmlReport", "koverHtmlReport") | ||
val checkerContext = build.createCheckerContext(buildResult) | ||
|
||
checkerContext.xml(defaultXmlReport()) { | ||
classCounter("kotlinx.kover.templates.ExampleClass").assertFullyMissed() | ||
} | ||
assertTrue(buildResult.isSuccessful) | ||
} | ||
|
||
private fun checkWithVerify(buildSource: BuildSource) { | ||
val build = buildSource.generate() | ||
val buildResult = build.runWithParams("koverXmlReport", "koverHtmlReport", "koverVerify") | ||
val checkerContext = build.createCheckerContext(buildResult) | ||
|
||
checkerContext.xml(defaultXmlReport()) { | ||
classCounter("kotlinx.kover.templates.ExampleClass").assertFullyMissed() | ||
} | ||
checkerContext.checkHtmlReport() | ||
assertFalse(buildResult.isSuccessful) | ||
assertContains(buildResult.output, "Rule violated: lines covered percentage is 0.000000, but expected minimum is 50") | ||
} | ||
|
||
} |
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
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
18 changes: 18 additions & 0 deletions
18
kover-gradle-plugin/src/functionalTest/templates/builds/no-tests-jvm/build.gradle.kts
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,18 @@ | ||
plugins { | ||
kotlin("jvm") version "1.8.20" | ||
id("org.jetbrains.kotlinx.kover") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
koverReport { | ||
defaults { | ||
verify { | ||
rule { | ||
minBound(50) | ||
} | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
kover-gradle-plugin/src/functionalTest/templates/builds/no-tests-jvm/settings.gradle.kts
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,8 @@ | ||
pluginManagement { | ||
repositories { | ||
gradlePluginPortal() | ||
mavenCentral() | ||
} | ||
} | ||
|
||
rootProject.name = "no-tests-jvm" |
17 changes: 17 additions & 0 deletions
17
...e-plugin/src/functionalTest/templates/builds/no-tests-jvm/src/main/kotlin/ExampleClass.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,17 @@ | ||
package kotlinx.kover.templates | ||
|
||
class ExampleClass { | ||
fun formatInt(i: Int): String { | ||
if (i == 0) return "ZERO" | ||
return if (i > 0) { | ||
"POSITIVE=$i" | ||
} else { | ||
"NEGATIVE=${-i}" | ||
} | ||
} | ||
|
||
fun printClass() { | ||
val name = this::class.qualifiedName | ||
println(name) | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
kover-gradle-plugin/src/functionalTest/templates/builds/no-tests-mpp/build.gradle.kts
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,27 @@ | ||
plugins { | ||
kotlin("multiplatform") version ("1.8.20") | ||
id ("org.jetbrains.kotlinx.kover") version "0.7.1" | ||
} | ||
|
||
kotlin { | ||
jvm() | ||
jvmToolchain(8) | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
/* | ||
* Kover configs | ||
*/ | ||
|
||
koverReport { | ||
defaults { | ||
verify { | ||
rule { | ||
minBound(50) | ||
} | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
kover-gradle-plugin/src/functionalTest/templates/builds/no-tests-mpp/settings.gradle.kts
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,8 @@ | ||
pluginManagement { | ||
repositories { | ||
gradlePluginPortal() | ||
mavenCentral() | ||
} | ||
} | ||
|
||
rootProject.name = "no-tests-mpp" |
17 changes: 17 additions & 0 deletions
17
...lugin/src/functionalTest/templates/builds/no-tests-mpp/src/jvmMain/kotlin/ExampleClass.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,17 @@ | ||
package kotlinx.kover.templates | ||
|
||
class ExampleClass { | ||
fun formatInt(i: Int): String { | ||
if (i == 0) return "ZERO" | ||
return if (i > 0) { | ||
"POSITIVE=$i" | ||
} else { | ||
"NEGATIVE=${-i}" | ||
} | ||
} | ||
|
||
fun printClass() { | ||
val name = this::class.qualifiedName | ||
println(name) | ||
} | ||
} |
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