Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin Power-Assert #67

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugins {
alias(libs.plugins.androidx.room)
alias(libs.plugins.detekt)
alias(libs.plugins.ktlint)
id("kotlin-power-assert")
}

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
}
}
7 changes: 7 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
`kotlin-dsl`
}

dependencies {
implementation(libs.kotlin.powerAssert.plugin)
}
13 changes: 13 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
dependencyResolutionManagement {
@Suppress("UnstableApiUsage")
repositories {
mavenCentral()
gradlePluginPortal()
}

versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
31 changes: 31 additions & 0 deletions buildSrc/src/main/kotlin/kotlin-power-assert.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
Loading