apollo-kotlin icon indicating copy to clipboard operation
apollo-kotlin copied to clipboard

In memory implementation for test

Open joeldenke opened this issue 3 years ago • 1 comments

Mock server requires a lot of boilerplate and locked into http protocol. Similar to Mock retrofit, would be amazing mock with test builders directly in ApolloClient query layer. Would then not need Idle resources or mock http server.

Similar concept having whenever(apollo.query()).assertThat(data, queryBuilder {}) instead would be neat inject this with Dagger into unit test and instrumentation test as androidx Room or Retrofit mock provides. As a separate implementation of ApolloClient as MockApolloClient. With your own coroutine dispatchers with new runTest{} api in Kotlin Test. And then inside provide in memory data with similar hamcrest or Kotlin DSL.

joeldenke avatar Dec 10 '21 18:12 joeldenke

I'd suggest we do this with a TestNetworkTransport. Follow up issue there

martinbonnin avatar Dec 16 '21 18:12 martinbonnin

Closing as TestNetworkTransport has been implemented a while ago. Don't hesitate to re-open as necessary.

BoD avatar Nov 03 '22 13:11 BoD