android / codelab-android-paging

Jetpack Paging codelab
Apache License 2.0
491 stars 260 forks source link

Request for test coverage #203

Open Gelassen opened 2 years ago

Gelassen commented 2 years ago

Hello,

Thanks for your work! Could you please add test coverage for common test scenarios?

I am moving from old paradigm (rxjava, model-view-presenter, etc) to a new one (data binding, view model, coroutines, etc) and looking for a right way to cover it with tests. In particular case I have screen with PagingDataAdapter and need to verify is there a call of showError() when API is set to return negative response from server.

In the past I would provide a view interface which will handle all operation on view layer within activity|fragment and mock it in the tests and call verify(view).invoke(showError()). Nowadays it looks like it is not a preferred way, PagingDataAdapter has addLoadStateListener() where, in theory, we also could provide mocks. I am working on this right now, but would like to see how Google team sees the right way to write tests for this and similar common cases.

p.s. I have read this your legal notice , as I haven't provided any code yet I leave this paperwork for later.