From f81627da81ee28a095f289a0795ca8f4686f78f4 Mon Sep 17 00:00:00 2001 From: Mohsen Mirhoseini Date: Mon, 24 Jun 2024 21:46:18 +0200 Subject: [PATCH] WIP --- app/build.gradle.kts | 1 + .../data/characters/dao/CharacterDaoTest.kt | 7 +++++ buildSrc/build.gradle.kts | 7 +++++ buildSrc/settings.gradle.kts | 13 ++++++++ .../kotlin/kotlin-power-assert.gradle.kts | 31 +++++++++++++++++++ gradle/libs.versions.toml | 2 ++ 6 files changed, 61 insertions(+) create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/settings.gradle.kts create mode 100644 buildSrc/src/main/kotlin/kotlin-power-assert.gradle.kts diff --git a/app/build.gradle.kts b/app/build.gradle.kts index cc51f24..7fe9598 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -8,6 +8,7 @@ plugins { alias(libs.plugins.androidx.room) alias(libs.plugins.detekt) alias(libs.plugins.ktlint) + id("kotlin-power-assert") } android { diff --git a/app/src/test/kotlin/com/mohsenoid/rickandmorty/data/characters/dao/CharacterDaoTest.kt b/app/src/test/kotlin/com/mohsenoid/rickandmorty/data/characters/dao/CharacterDaoTest.kt index 9c646d5..eb13c58 100644 --- a/app/src/test/kotlin/com/mohsenoid/rickandmorty/data/characters/dao/CharacterDaoTest.kt +++ b/app/src/test/kotlin/com/mohsenoid/rickandmorty/data/characters/dao/CharacterDaoTest.kt @@ -99,4 +99,11 @@ class CharacterDaoTest { assertTrue(actualEpisodes.contains(expectedEntity)) assertFalse(actualEpisodes.contains(unexpectedEntity)) } + + @Test + fun testFunction() { + val hello = "Hello" + val world = "world!" + assert(hello.length == world.substring(1, 4).length) { "Incorrect length" } + } } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000..598b24c --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + `kotlin-dsl` +} + +dependencies { + implementation(libs.kotlin.powerAssert.plugin) +} diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts new file mode 100644 index 0000000..b55500c --- /dev/null +++ b/buildSrc/settings.gradle.kts @@ -0,0 +1,13 @@ +dependencyResolutionManagement { + @Suppress("UnstableApiUsage") + repositories { + mavenCentral() + gradlePluginPortal() + } + + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } +} diff --git a/buildSrc/src/main/kotlin/kotlin-power-assert.gradle.kts b/buildSrc/src/main/kotlin/kotlin-power-assert.gradle.kts new file mode 100644 index 0000000..2066a36 --- /dev/null +++ b/buildSrc/src/main/kotlin/kotlin-power-assert.gradle.kts @@ -0,0 +1,31 @@ +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi + +plugins { + id("org.jetbrains.kotlin.plugin.power-assert") +} + +@OptIn(ExperimentalKotlinGradlePluginApi::class) +powerAssert { + functions = listOf( + "kotlin.assert", + "kotlin.test.assertContains", + "kotlin.test.assertContentEquals", + "kotlin.test.assertEquals", + "kotlin.test.assertFails", + "kotlin.test.assertFailsWith", + "kotlin.test.assertFalse", + "kotlin.test.assertIs", + "kotlin.test.assertIsNot", + "kotlin.test.assertNotContains", + "kotlin.test.assertNotEquals", + "kotlin.test.assertNotNull", + "kotlin.test.assertNotSame", + "kotlin.test.assertNull", + "kotlin.test.assertSame", + "kotlin.test.assertTrue", + "kotlin.test.expect", + "kotlin.test.fail", + ) + + includedSourceSets = listOf("test","androidTest") +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 83d94ef..b920137 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -59,6 +59,8 @@ okhttp3-mockWebServer = { group = "com.squareup.okhttp3", name = "mockwebserver" coil = { group = "io.coil-kt", name = "coil-compose", version.ref = "coil" } turbine = { group = "app.cash.turbine", name = "turbine", version.ref = "turbine" } +kotlin-powerAssert-plugin = { group = "org.jetbrains.kotlin.plugin.power-assert", name = "org.jetbrains.kotlin.plugin.power-assert.gradle.plugin", version.ref = "kotlin" } + [bundles] retrofit = ["retrofit-retrofit", "retrofit-converter-gson"]