How do I create a PagedList of an object for tests?

后端 未结 3 488
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-07 05:26

I have been working with the arch libraries from Google, but one thing that has made testing difficult is working with PagedList.

For this example, I am usi

3条回答
  •  执笔经年
    2021-02-07 05:51

    1. You cannot cast List to PagedList.
    2. You cannot create PagedList directly, only through DataSource. One way is creating FakeDataSource returning the test data.

    If it is an end-to-end test, you could just use in-memory db. Add your test data before calling it. Example: https://medium.com/exploring-android/android-architecture-components-testing-your-room-dao-classes-e06e1c9a1535

提交回复
热议问题