Skip to content

Task .await() extension function blocks main thread indefinitely in tests #3004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pmoons opened this issue Oct 28, 2021 · 1 comment
Closed
Labels

Comments

@pmoons
Copy link

pmoons commented Oct 28, 2021

Granted, I am new to Kotlin and, by extension, some of the coroutine and flow paradigms in the language, but I have been running into a roadblock for the past few days with the use of .await() in tests. I have been trying to write an integration test for the repository layer of an Android app that verifies, given a running local Firestore emulator, when populated with certain values, then calling the repository method will return a subset of those values. My tests hang indefinitely, and I have narrowed it down to the .await() extension function (not the Tasks.await() method).

I have created a repo that shows the problem I am having. A part of me believes that perhaps this recently worked on issue may fix the problem I am experiencing, but it hasn't been released yet, and it is marked as an "Enhancement" and not a "Bug Fix".

I am trying to see:

  • If there is some bug with the use of .await() in tests. Perhaps the runBlocking Coroutine Scope doesn't "play" nicely with .await(), which would be a shame, since the Android community is taught to use this (or runBlockingTest) in tests.
  • If there is not a bug, how would one test such code with .await()? I have a lot of difficulty finding examples online of tests that use .await() within a runBlocking context.
@pmoons
Copy link
Author

pmoons commented Nov 25, 2021

This problem is resolved in 1.6.0-RC release. See git changes: https://github.com/pmoons/TaskAwaitIssue/compare/fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants