Тёмный

Testing Coroutines on Android (Android Dev Summit '19) 

Android Developers
Подписаться 1,3 млн
Просмотров 43 тыс.
50% 1

Coroutines simplify the way we do async programming on Android. However, testing async code has never been an easy task. In this talk, we show you how to master testing asynchronicity with coroutines to get that precious green check ✔️. Which questions do you have to ask yourself before writing a line of test code? How can you test coroutines that use Dispatchers.Main? What if you want to control the timing of your events? Why shouldn't you use Dispatchers.Unconfined? Come and learn how to test coroutines like a pro.
Presented by: Manuel Vivo, Sean McQuillan
Android Dev Summit '19 all sessions playlist → goo.gle/ADS19allsessions
Subscribe to the Android Developers channel! → goo.gle/AndroidDevs
Check out the photo album → goo.gle/ADS19Photos
#AndroidDevSummit event: Android Dev Summit 2019; re_ty: Publish; product: Android - Languages; fullname: Manuel Vivo, Sean McQuillan;

Наука

Опубликовано:

 

23 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 14   
@adamhurwitz
@adamhurwitz 4 года назад
runBlockingTest - 6:20 TestCoroutineDispatcher - 11:05
@daynyong
@daynyong 2 года назад
Thanks for the great video. It seems that Deferred(result of coroutine async function) inherits Job which is cancellable. Has async implementation changed after this video or have I misunderstood 'suspend vs deferred' part?
@pedromoniz4224
@pedromoniz4224 4 года назад
Is there any resource for what that MainCoroutinerule actually is? There is little documentation and all these mechanisms require a bunch of prep, dunno why you jumped over it. Also, how does this mechanism affect live data? I also have a mechanism that allows me to run the work on IO and resolve the work in MAIN. So not only I have launch I also have async await. Any way to test this?
@seanmcquillan7834
@seanmcquillan7834 4 года назад
Yep, it's not in a library (we didn't want to add any JUnit dependencies to kotlinx-coroutines-test), but this one by Rick Busarrow is a good place to start: gist.github.com/RBusarow/70256d782e2d789cfa167a0163b2e22e
@revm4942
@revm4942 4 года назад
​@@seanmcquillan7834 Hi I have a question, on the example above the coroutine was launched with viewModelScope right and it uses Dispatchers.Main as default, what if I want to use Dispatchers.IO when inserting an entry in the Database, can I just wrap the suspend function body in the repository with `withContext(Dispatchers.IO)` and still test it with `runBlockingTest` right?
@igorg.8624
@igorg.8624 4 года назад
Is there a google sample for this approach on Github?
@coonskinniggs
@coonskinniggs 2 года назад
There is a well written code-lab named Advanced Android Testing [5.1 to 5.3] which covers all the good testing stuff. FYI, I know it's a very late reply. :D
@RakhiDhavale
@RakhiDhavale 4 года назад
Please mention the link to the repository where there are test cases for coroutines as per documentation
@jerarcaarthanis1461
@jerarcaarthanis1461 4 года назад
still waiting for this hehe
@samp2300
@samp2300 2 года назад
I didn't get the point of the graph at the end of the video
@antoniokomangyudistira4150
@antoniokomangyudistira4150 4 года назад
Ughhh confused
Далее
Understanding Compose (Android Dev Summit '19)
36:15
Просмотров 71 тыс.
Корутины
1:51:55
Просмотров 13 тыс.
Kotlin Flows in practice
21:06
Просмотров 154 тыс.
What is good posture? Dr. Ken Silva explains.
1:31
Просмотров 79 тыс.
PERFECT 5 Minute Posture Routine (FIX YOUR SIT!)
0:52
The ABC of Coroutines - Kotlin Vocabulary
9:27
Просмотров 49 тыс.
Advanced layout animations in Compose (Shared elements)
30:33
iPhone 16 - НЕ СТОИТ ПРОПУСКАТЬ
4:50
Samsung laughing on iPhone #techbyakram
0:12
Просмотров 680 тыс.
Здесь упор в процессор
18:02
Просмотров 384 тыс.