在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):msesma/Karchitec开源软件地址(OpenSource Url):https://github.com/msesma/Karchitec开源编程语言(OpenSource Language):Kotlin 99.6%开源软件介绍(OpenSource Introduction):KarchitecKotlin RSS reader using Google android architecture components librariesPet project for testing several technologies:
Simple RSS reader for technology testing. It is mostly a pet project to test the architecture components in kotlin. Instead using a fragment as View, here we use a decorator class in order to maintain the activities as clean as possible. There is also a presenter for removing the not Data related logic from the ViewModel. A time limited OkHttp caché acts as rate limiter avoiding network calls before 30 seconds after the last one. Some sites can overwrite this time. More information about the architecture implemented in this post. Error management and network status:Instead creating an object that wraps network state and the actual data, here a second LiveData is used. This LiveData is feeded by the repository with interpreted results of Network calls. This LiveData is also stored in the MainActivity ViewModel and the decorator subscribes to it as it does with the data one. this way, errors are also lifecycle aware. This approach is simple and effective, keeping the responsibilities separated. Detail activity never does network calls so it doesn't use the error flow. Espresso tests:Creating a mock repository class that returns mock MutableLiveData with controlled data is enough to easily test anything we want on the UI. We coud even test errors mocking also the network error LiveData. I've left there the code for IdLingResource although it is not extrictly necessary using a fake Repository. With real repositories we must wait until the activity is iddle to ensure the data has arrived and the recyclerView is rendered. JUnit testsWebservice and mappers (RefreshUseCase) are tested using MockWebServer and a TestExecutor. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论