Skip to content

Commit

Permalink
Merge pull request #193 from monosoul/fix/coverage
Browse files Browse the repository at this point in the history
fix(test): coverage report
  • Loading branch information
monosoul authored Apr 2, 2024
2 parents 68d0fb2 + e67d389 commit e8f16ae
Show file tree
Hide file tree
Showing 32 changed files with 96 additions and 40 deletions.
4 changes: 3 additions & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@
"automerge": true,
"automergeStrategy": "squash",
"platformAutomerge": true,
"ignoreDeps": [],
"ignoreDeps": [
"gradle"
],
"reviewers": [
"monosoul"
]
Expand Down
75 changes: 75 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import java.lang.Thread.sleep
import java.time.Duration

plugins {
`kotlin-dsl`
`kotlin-convention`
Expand Down Expand Up @@ -59,3 +62,75 @@ dependencies {
testFixturesApi(libs.mockk)
testFixturesApi(gradleTestKit())
}

val functionalTestSuiteName = "functionalTest"
val extraTestSuiteName = "extraTest"

@Suppress("UnstableApiUsage")
testing {
suites {
register<JvmTestSuite>(functionalTestSuiteName) {
useJUnitJupiter()
dependencies {
implementation(project())
implementation(testFixtures(project()))
runtimeOnly(files(tasks.pluginUnderTestMetadata))
}

targets {
all {
testTask.configure {
dependsOn(tasks.pluginUnderTestMetadata)
shouldRunAfter(tasks.test)
extensions.configure<JacocoTaskExtension> {
isEnabled = false
}

// workaround for https://github.com/gradle/gradle/issues/16603
doLast {
sleep(
Duration.ofSeconds(2).toMillis(),
)
}
}
}
}
}

register<JvmTestSuite>(extraTestSuiteName) {
/**
* This test suite is required because Gradle doesn't support Java agents
* when using TestKit with configuration cache enabled
*
* https://docs.gradle.org/7.5.1/userguide/configuration_cache.html#config_cache:not_yet_implemented:testkit_build_with_java_agent
*/

useJUnitJupiter()
dependencies {
implementation(project())
implementation(testFixtures(project()))
runtimeOnly(files(tasks.pluginUnderTestMetadata))
}

targets {
all {
testTask.configure {
dependsOn(tasks.pluginUnderTestMetadata)
shouldRunAfter(tasks.test)
extensions.configure<JacocoTaskExtension> {
isEnabled = false
}
}
}
}
}
}
}

jacocoTestKit {
applyTo("${functionalTestSuiteName}RuntimeOnly", tasks.named(functionalTestSuiteName))
}

tasks.check {
dependsOn(tasks.named(functionalTestSuiteName), tasks.named(extraTestSuiteName))
}
19 changes: 6 additions & 13 deletions buildSrc/src/main/kotlin/coverage-convention.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
import java.lang.Thread.sleep
import java.time.Duration

plugins {
kotlin("jvm")
jacoco
id("pl.droidsonroids.jacoco.testkit")
}

tasks {
val testTasks = tasks.withType<Test>()
jacocoTestReport {
executionData.setFrom(
testTasks.map { it.extensions.getByType<JacocoTaskExtension>().destinationFile }
)

reports {
xml.required.set(true)
html.required.set(false)
}
dependsOn(withType<Test>())
}

withType<Test> {
// workaround for https://github.com/gradle/gradle/issues/16603
doLast {
sleep(
Duration.ofSeconds(2).toMillis()
)
}
shouldRunAfter(testTasks)
}
}
9 changes: 9 additions & 0 deletions buildSrc/src/main/kotlin/kotlin-convention.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ java {
targetCompatibility = targetJava
}

testing {
suites {
@Suppress("UnstableApiUsage")
named<JvmTestSuite>("test") {
useJUnitJupiter()
}
}
}

tasks {
withType<Test> {
useJUnitPlatform()
Expand Down
23 changes: 0 additions & 23 deletions extra-tests/build.gradle.kts

This file was deleted.

2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
rootProject.name = "jooq-gradle-plugin"

include("extra-tests", "artifact-tests")
include("artifact-tests")

dependencyResolutionManagement {
versionCatalogs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import strikt.api.expect
import strikt.assertions.isEqualTo
import strikt.java.exists

class ConfigurabilityJooqDockerPluginFunctionalTest : JooqDockerPluginFunctionalTestBase() {
class ConfigurabilityJooqDockerPluginFunctionalTest : dev.monosoul.jooq.functional.JooqDockerPluginFunctionalTestBase() {
@Test
fun `should generate jooq classes for PostgreSQL db with default config for multiple schemas`() {
// given
Expand Down

0 comments on commit e8f16ae

Please sign in to comment.