Create Unit Test of MVVM LiveData with Observable and CountdownLatch

Опубликовано: 11 Февраль 2022
на канале: Brandan Jones
2,461
32

In this video, I create and explain how to write a Test Driven Design Unit Test for a View Model with observable LiveData, and validate the data that is observed through LiveData. It's a little tricky, as we have to wait for data to be observed before we can run asserts on it. So, I create MockK mock of the service class that provides the data, an Observable object to observe the data, and then a CountdownLatch to determine when the observable has observed the LiveData changing. I simply write the unit test in this video, I have a follow up video where I implement the classes and make the tests pass. However, I am able to demontrate this unit test passing by using another project, which I have completed.

All source code is freely available in GitHub: https://github.com/discospiff/MyPlant...
This video is part of a playlist on creating Android apps with Jetpack Compose, which is avialable here:    • Create an Android app with Jetpack Co...  


Смотрите видео Create Unit Test of MVVM LiveData with Observable and CountdownLatch онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Brandan Jones 11 Февраль 2022, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 2,46 раз и оно понравилось 3 людям.