Skip to content

Async Testing ‐ Testing normal functions that launch a coroutine

Devrath edited this page Oct 25, 2023 · 8 revisions

github-header-image (3)

Scenario

  • Most of the time we come across scenarios where the system under test(SUT) is a normal function.
  • But this normal function launches a new co-routine and performs some action in an async way.
  • If the function was a suspend function, We could have used a run-blocking way to test it on the test case so the test case does not finish until the suspend function finishes the execution.
  • This is more common where a view calls a function in a view-model and the view-model launches a co-routine.
  • Since the launched co-routine is independent we will not be able to use a run-blocking function.

Clone this wiki locally