Skip to content
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

Upgrade coroutines to 1.6.4 (including coroutines.test changes) #817

Merged
merged 1 commit into from
Jul 26, 2022

Conversation

steve-the-edwards
Copy link
Contributor

@steve-the-edwards steve-the-edwards commented Jun 22, 2022

For non-test use we had already migrated from offer to trySend for channels.

For tests (the larger change), see the test migration guide followed here: https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-test/MIGRATION.md

This has been tested successfully internally in Square POS via a snapshot.

Regarding whether we should convert all runBlocking to runTest when used in tests, its a choice for each situation (we have converted many but not all). See Dmitry Khalanskiy's (coroutines maintainer) to that question:

If you're not relying on virtual time, you can stick with runBlocking, it's just a bit less convenient:
There's no runBlocking on JS, so the test won't be usable in multiplatform code. This was the message behind the line: 1.6 introduced multiplatform coroutine testing.
runBlocking returns the value that its block returns. JUnit, for example, expects the test functions to return Unit. So, something like @test fun test() = runBlocking { assertFailsWith { throw IllegalArgumentException() } } will, surprisingly, not be executed by JUnit, because test() returns an IllegalArgumentException.
runTest is purely for tests, which means we can enhance it with other niceties that have no place in production code. For example, we recently added a way to cancel some of the coroutines in a test when the test body finishes: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-scope/background-scope.html You won't have that with runBlocking.

@steve-the-edwards steve-the-edwards changed the title WIP: Upgrade coroutines to 1.6.1 Upgrade coroutines to 1.6.1 Jun 22, 2022
@steve-the-edwards steve-the-edwards force-pushed the coroutines_1.6 branch 3 times, most recently from b0223ab to 13ff21c Compare June 22, 2022 21:37
And update usages according to migratino guide.
@steve-the-edwards steve-the-edwards marked this pull request as ready for review July 18, 2022 20:25
Copy link

@vgonda vgonda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet! Learn stuff we can apply to register? 😉

@steve-the-edwards steve-the-edwards changed the title Upgrade coroutines to 1.6.1 Upgrade coroutines to 1.6.4 (include coroutines.test changes) Jul 21, 2022
@steve-the-edwards steve-the-edwards changed the title Upgrade coroutines to 1.6.4 (include coroutines.test changes) Upgrade coroutines to 1.6.4 (including coroutines.test changes) Jul 21, 2022
@steve-the-edwards steve-the-edwards merged commit 0ae7867 into main Jul 26, 2022
@steve-the-edwards steve-the-edwards deleted the coroutines_1.6 branch July 26, 2022 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants