Skip to content

Commit

Permalink
add test for coVerifyCount
Browse files Browse the repository at this point in the history
  • Loading branch information
T45K committed Mar 13, 2024
1 parent d33a024 commit 6986922
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions modules/mockk/src/commonTest/kotlin/io/mockk/it/CoVerifyTest.kt
@@ -1,9 +1,15 @@
package io.mockk.it

import io.mockk.*
import kotlinx.coroutines.coroutineScope
import io.mockk.InternalPlatformDsl
import io.mockk.coEvery
import io.mockk.coVerify
import io.mockk.coVerifyCount
import io.mockk.coVerifyOrder
import io.mockk.coVerifySequence
import io.mockk.mockk
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlinx.coroutines.coroutineScope

class CoVerifyTest {
class MockCls {
Expand All @@ -12,7 +18,7 @@ class CoVerifyTest {

val mock = mockk<MockCls>()

fun doCalls() {
private fun doCalls() {
coEvery { mock.op(5) } returns 1
coEvery { mock.op(6) } returns 2
coEvery { mock.op(7) } returns 3
Expand Down Expand Up @@ -156,4 +162,18 @@ class CoVerifyTest {
mock.op(7)
}
}

@Test
fun verifyCount() {
doCalls()

coVerifyCount {
0 * { mock.op(4) } // not called
1 * { mock.op(5) } // called
(0..Int.MAX_VALUE) * { mock.op(6) } // called
(1..1) * { mock.op(7) } // called
(0..0) * { mock.op(8) } // not called
(0..1) * { mock.op(9) } // not called
}
}
}

0 comments on commit 6986922

Please sign in to comment.