Create a coJustAwait
function similar to coJustRun
#924
Closed
SimonMarquis
started this conversation in
Ideas
Replies: 4 comments
-
Generally speaking, I'd say this makes sense. Can you provide a code example of how you would expect this to work, though? |
Beta Was this translation helpful? Give feedback.
0 replies
-
/**
* Stub block to never return.
*
* Used to define what behaviour is going to be mocked.
* @see [io.mockk.coJustRun]
*/
fun coJustAwait(
stubBlock: suspend MockKMatcherScope.() -> Unit,
) = coEvery(stubBlock) coAnswers {
awaitCancellation()
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
In the meantime, here is what it would look like in the code base #927 |
Beta Was this translation helpful? Give feedback.
0 replies
-
The PR has been merged, this discussion can be closed as answered. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
👋 Hi,
Would you be open to add a
coJustAwait
, similar tocoJustRun
?This function would simply stub the given block to wait indefinitely (until cancellation).
It could be used to mockk a suspend function to never return.
This can be especially usefull to test intermediate states, without having to explicitely specify coroutine dispatchers, and to prevent early returns.
Beta Was this translation helpful? Give feedback.
All reactions