apollographql / apollo-kotlin

:rocket:  A strongly-typed, caching GraphQL client for the JVM, Android, and Kotlin multiplatform.
https://www.apollographql.com/docs/kotlin
MIT License
3.74k stars 653 forks source link

In memory implementation for test #3681

Closed joeldenke closed 1 year ago

joeldenke commented 2 years ago

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.

martinbonnin commented 2 years ago

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

BoD commented 1 year ago

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