Skip to content

Commit ceeffae

Browse files
committed
Use kotest
1 parent dd468a4 commit ceeffae

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

composeApp/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ plugins {
77
alias(libs.plugins.composeCompiler)
88
alias(libs.plugins.jetbrainsCompose)
99
alias(libs.plugins.kotlinxSerialization)
10+
alias(libs.plugins.kotest)
1011
}
1112

1213
kotlin {
@@ -56,7 +57,7 @@ kotlin {
5657
}
5758

5859
commonTest.dependencies {
59-
implementation(kotlin("test"))
60+
implementation(libs.kotest.framework.engine)
6061

6162
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
6263
implementation(compose.uiTest)

composeApp/src/commonTest/kotlin/ExampleTest.kt

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,33 @@ import androidx.compose.runtime.*
33
import androidx.compose.ui.Modifier
44
import androidx.compose.ui.platform.testTag
55
import androidx.compose.ui.test.*
6-
import kotlin.test.Test
7-
8-
class ExampleTest {
6+
import io.kotest.core.spec.style.FunSpec
97

8+
class ExampleTest : FunSpec({
109
@OptIn(ExperimentalTestApi::class)
11-
@Test
12-
fun myTest() = runComposeUiTest {
13-
// Declares a mock UI to demonstrate API calls
14-
//
15-
// Replace with your own declarations to test the code of your project
16-
setContent {
17-
var text by remember { mutableStateOf("Hello") }
18-
Text(
19-
text = text,
20-
modifier = Modifier.testTag("text")
21-
)
22-
Button(
23-
onClick = { text = "Compose" },
24-
modifier = Modifier.testTag("button")
25-
) {
26-
Text("Click me")
10+
test("smoke test") {
11+
runComposeUiTest {
12+
// Declares a mock UI to demonstrate API calls
13+
//
14+
// Replace with your own declarations to test the code of your project
15+
setContent {
16+
var text by remember { mutableStateOf("Hello") }
17+
Text(
18+
text = text,
19+
modifier = Modifier.testTag("text")
20+
)
21+
Button(
22+
onClick = { text = "Compose" },
23+
modifier = Modifier.testTag("button")
24+
) {
25+
Text("Click me")
26+
}
2727
}
28-
}
2928

30-
// Tests the declared UI with assertions and actions of the Compose Multiplatform testing API
31-
onNodeWithTag("text").assertTextEquals("Hello")
32-
onNodeWithTag("button").performClick()
33-
onNodeWithTag("text").assertTextEquals("Compose")
29+
// Tests the declared UI with assertions and actions of the Compose Multiplatform testing API
30+
onNodeWithTag("text").assertTextEquals("Hello")
31+
onNodeWithTag("button").performClick()
32+
onNodeWithTag("text").assertTextEquals("Compose")
33+
}
3434
}
35-
}
35+
})

gradle/libs.versions.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ kotlin = "2.1.0"
66
kotlinx-coroutines = "1.10.1"
77
ktor = "3.0.1"
88
kaml = "0.67.0"
9+
kotest = "6.0.0.M1"
910

1011
[libraries]
1112
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
@@ -18,10 +19,12 @@ ktor-client-core = { group = "io.ktor", name = "ktor-client-core", version.ref =
1819
ktor-client-js = { group = "io.ktor", name = "ktor-client-js", version.ref = "ktor" }
1920
ktor-client-cio = { group = "io.ktor", name = "ktor-client-cio", version.ref = "ktor" }
2021
kaml = { group = "com.charleskorn.kaml", name = "kaml", version.ref = "kaml" }
22+
kotest-framework-engine = { group = "io.kotest", name = "kotest-framework-engine", version.ref = "kotest" }
2123

2224
[plugins]
2325
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
2426
composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
2527
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
2628
kotlinxSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
29+
kotest = { id = "io.kotest.multiplatform", version.ref = "kotest" }
2730

0 commit comments

Comments
 (0)