From 9bcbc3ffd1643599ff0ec3115509214775a76757 Mon Sep 17 00:00:00 2001 From: Manuel Andruccioli Date: Sun, 11 Feb 2024 23:29:31 +0100 Subject: [PATCH] feat(repo): add kotest for testing --- build-logic/src/main/kotlin/Utils.kt | 5 +++++ build-logic/src/main/kotlin/kotlin-base.gradle.kts | 14 ++++++++++++++ gradle/libs.versions.toml | 12 ++++++++---- 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 build-logic/src/main/kotlin/Utils.kt diff --git a/build-logic/src/main/kotlin/Utils.kt b/build-logic/src/main/kotlin/Utils.kt new file mode 100644 index 000000000..1c0a3de25 --- /dev/null +++ b/build-logic/src/main/kotlin/Utils.kt @@ -0,0 +1,5 @@ +import org.gradle.api.artifacts.MinimalExternalModuleDependency +import org.gradle.api.artifacts.VersionCatalog +import org.gradle.api.provider.Provider + +fun VersionCatalog.getLibrary(name: String): Provider = findLibrary(name).get() diff --git a/build-logic/src/main/kotlin/kotlin-base.gradle.kts b/build-logic/src/main/kotlin/kotlin-base.gradle.kts index e744d969b..e13c7a860 100644 --- a/build-logic/src/main/kotlin/kotlin-base.gradle.kts +++ b/build-logic/src/main/kotlin/kotlin-base.gradle.kts @@ -7,3 +7,17 @@ plugins { ktfmt { kotlinLangStyle() } + +val catalog = extensions.getByType().named("libs") + +dependencies { + testImplementation(catalog.getLibrary("kotest")) +} + +tasks.test { + useJUnitPlatform() +} + +kotlin { + jvmToolchain(17) +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index dc4835555..89bf3dd2c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,11 +2,15 @@ # https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format [versions] -kotlin = "1.9.22" -ktfmt = "0.17.0" detekt = "1.23.5" +ktfmt = "0.17.0" +kotest = "5.8.0" +kotlin = "1.9.22" + +[libraries] +kotest = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" } [plugins] -kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } -ktfmt = { id = "com.ncorti.ktfmt.gradle", version.ref = "ktfmt" } detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" } +ktfmt = { id = "com.ncorti.ktfmt.gradle", version.ref = "ktfmt" } +kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }