Skip to content

Commit

Permalink
Switch from truth to assertk
Browse files Browse the repository at this point in the history
  • Loading branch information
ansman committed Apr 12, 2023
1 parent 4e33bdf commit 3d9bdd9
Show file tree
Hide file tree
Showing 15 changed files with 215 additions and 100 deletions.
4 changes: 3 additions & 1 deletion api/src/test/kotlin/se/ansman/kotshi/TestKotshiUtils.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package se.ansman.kotshi

import com.google.common.truth.Truth.assertThat
import assertk.assertThat
import assertk.assertions.isEqualTo
import assertk.assertions.isNotEqualTo
import com.squareup.moshi.JsonQualifier
import org.junit.Test
import se.ansman.kotshi.KotshiUtils.createJsonQualifierImplementation
Expand Down
2 changes: 1 addition & 1 deletion gradle-plugin/src/main/kotlin/library.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ tasks.withType<Javadoc> { enabled = false }

dependencies {
testImplementation(libs.junit)
testImplementation(libs.truth)
testImplementation(libs.assertk)
testImplementation(libs.kotlin.test.junit)
}
2 changes: 2 additions & 0 deletions gradle-plugin/src/main/kotlin/test-library.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ sourceSets {
}

tasks.withType<Test>().configureEach {
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
jvmArgs(
"--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
Expand All @@ -28,6 +29,7 @@ tasks.withType<Test>().configureEach {
"--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
)
}

dependencies {
implementation(project(":api"))
Expand Down
2 changes: 1 addition & 1 deletion libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ kotlinpoet-ksp = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlin
kotlinx-metadata = "org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.5.0"

junit = "junit:junit:4.12"
truth = "com.google.truth:truth:1.1.3"
assertk = "com.willowtreeapps.assertk:assertk-jvm:0.25"

compileTesting-core = { module = "com.github.tschuchortdev:kotlin-compile-testing", version.ref = "compileTesting" }
compileTesting-ksp = { module = "com.github.tschuchortdev:kotlin-compile-testing-ksp", version.ref = "compileTesting" }
Expand Down
12 changes: 7 additions & 5 deletions tests/ksp/src/test/kotlin/se/ansman/kotshi/KspGeneratorTest.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package se.ansman.kotshi

import assertk.assertThat
import assertk.assertions.isEqualTo
import com.tschuchort.compiletesting.KotlinCompilation
import com.tschuchort.compiletesting.SourceFile
import com.tschuchort.compiletesting.kspArgs
Expand Down Expand Up @@ -36,7 +38,7 @@ class KspGeneratorTest : BaseGeneratorTest() {
)

with(compile(factory)) {
com.google.common.truth.Truth.assertThat(exitCode)
assertThat(this::exitCode)
.isEqualTo(KotlinCompilation.ExitCode.OK)
assertEquals(
"""
Expand Down Expand Up @@ -75,7 +77,7 @@ class KspGeneratorTest : BaseGeneratorTest() {
""".trimIndent()
)
with(compile(factory, object1)) {
com.google.common.truth.Truth.assertThat(exitCode)
assertThat(this::exitCode)
.isEqualTo(KotlinCompilation.ExitCode.OK)
assertEquals(
"""
Expand Down Expand Up @@ -125,7 +127,7 @@ class KspGeneratorTest : BaseGeneratorTest() {
""".trimIndent()
)
with(compile(factory, object1, object2)) {
com.google.common.truth.Truth.assertThat(exitCode)
assertThat(this::exitCode)
.isEqualTo(KotlinCompilation.ExitCode.OK)
assertEquals(
"""
Expand Down Expand Up @@ -177,7 +179,7 @@ class KspGeneratorTest : BaseGeneratorTest() {
""".trimIndent()
)
with(compile(factory, object1, object2)) {
com.google.common.truth.Truth.assertThat(exitCode)
assertThat(this::exitCode)
.isEqualTo(KotlinCompilation.ExitCode.OK)
assertEquals(
"""
Expand Down Expand Up @@ -223,7 +225,7 @@ class KspGeneratorTest : BaseGeneratorTest() {
}

with(compile(factory, object2)) {
com.google.common.truth.Truth.assertThat(exitCode)
assertThat(this::exitCode)
.isEqualTo(KotlinCompilation.ExitCode.OK)
assertEquals(
"""
Expand Down
Loading

0 comments on commit 3d9bdd9

Please sign in to comment.