Skip to content

Commit 9113eba

Browse files
ansmanevant
authored andcommitted
Move the test to the common module
1 parent f62b753 commit 9113eba

File tree

3 files changed

+24
-29
lines changed

3 files changed

+24
-29
lines changed

assertk/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ kotlin {
2929
dependencies {
3030
implementation(kotlin("test"))
3131
implementation(libs.kotlinx.coroutines)
32+
implementation(libs.kotlinx.coroutines.test)
3233
}
3334
kotlin.srcDir(compileTestTemplates)
3435
}

assertk/src/commonTest/kotlin/test/assertk/AssertFailureTest.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@ package test.assertk
22

33
import assertk.assertFailure
44
import assertk.assertions.isEqualTo
5+
import assertk.assertions.isInstanceOf
56
import assertk.assertions.message
67
import com.willowtreeapps.opentest4k.AssertionFailedError
8+
import kotlinx.coroutines.test.runTest
79
import test.assertk.assertions.valueOrFail
10+
import kotlin.coroutines.resume
11+
import kotlin.coroutines.resumeWithException
12+
import kotlin.coroutines.suspendCoroutine
813
import kotlin.test.Test
914
import kotlin.test.assertEquals
1015
import kotlin.test.assertFailsWith
@@ -35,4 +40,22 @@ class AssertFailureTest {
3540
}
3641
assertEquals("expected failure but lambda completed successfully", t.message)
3742
}
43+
44+
@Test
45+
fun suspending_functions_can_succeed() = runTest {
46+
val t = assertFailsWith<AssertionFailedError> {
47+
assertFailure {
48+
suspendCoroutine { it.resume(Unit) }
49+
}
50+
}
51+
assertEquals("expected failure but lambda completed successfully", t.message)
52+
}
53+
54+
@Test
55+
fun suspending_functions_fail() = runTest {
56+
val t = assertFailure {
57+
suspendCoroutine { it.resumeWithException(IllegalArgumentException()) }
58+
}
59+
t.isInstanceOf<IllegalArgumentException>()
60+
}
3861
}

assertk/src/jvmTest/kotlin/test/assertk/JVMAssertFailureTest.kt

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)