-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Eagerly enter launch
and async
blocks with unconfined dispatcher.
#3011
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
Eagerly enter launch
and async
blocks with unconfined dispatcher.
#3011
Conversation
Also, fix `Dispatchers.Main` not delegating `Delay` methods and discover that, on JS, `Dispatchers.Main` gets reset during the test if it is reset in `AfterTest`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat!
* | ||
* ``` | ||
* @Test | ||
* fun testEagerlyEnteringChildCoroutines() = runTest(UnconfinedTestDispatcher()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, what do you think about providing runTestUnconfined
for a better migration path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like it because of this confusing behavior:
val ctx = StandardTestDispatcher()
@Test
fun test() = runTestUnconfined(ctx) {
// not unconfined
}
I added separate |
43cecf5
to
61461a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What an elegant idea with @NoPlatform
annotation!
|
Also, fix `Dispatchers.Main` not delegating `Delay` methods and discover that, on JS, `Dispatchers.Main` gets reset during the test if it is reset in `AfterTest`.
Also, fix `Dispatchers.Main` not delegating `Delay` methods and discover that, on JS, `Dispatchers.Main` gets reset during the test if it is reset in `AfterTest`.
Also, fix `Dispatchers.Main` not delegating `Delay` methods and discover that, on JS, `Dispatchers.Main` gets reset during the test if it is reset in `AfterTest`.
@qwwdfsad found a convenient migration path for most tests that rely on
launch
andasync
blocks being entered eagerly. Implemented it here.Also, I fixed
Dispatchers.Main
not delegatingDelay
methods and discovered that, on JS,Dispatchers.Main
gets reset during the test if it is reset inAfterTest
.