What is the current preferred method to test functions in commonMain that can take some time, like API calls? On the Android side I fund the CountDownLatch/.await works well. Is there a similar approach using coroutines test that I can use in commonTest? Thank you!
c
CLOVIS
08/01/2024, 7:37 AM
What behavior are you trying to test, exactly?
If you want to test the returned value, you can just
suspend
until the function finishes.
t
tylerwilson
08/01/2024, 12:57 PM
I am making an API call, which is defined as having a trailing closure. So something like:
Copy code
apiCall(param1, param2) { success, exception ->
}
note it is not defined as suspend. So I just need to know how I can "suspend until the function finishes".