kosi-libs / MocKMP

A mocking processor for Kotlin Multiplatform
https://kosi-libs.org/mockmp
MIT License
183 stars 12 forks source link

Would be nice if suspending function setup did not require you to be in suspend function #60

Closed dalewking closed 1 year ago

dalewking commented 1 year ago

It would be nice if calls like registerSuspend, everySuspend, and verifyWithSuspend were not suspend functions. If you look at MockK for comparison its equivalents like coEvery and coVerify are not suspending functions and they just internally wrap the calls to the suspending block in a runBlocking.

SalomonBrys commented 1 year ago

That is on purpose. We provide both *Suspend and * functions, to be used in both a suspending or a regular environment. Using runBlocking might break test coroutines if their mocked implementation suspends.