-
Notifications
You must be signed in to change notification settings - Fork 655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TestNetworkTransport #3737
Labels
Comments
martinbonnin
added
✨ Type: Feature
👋 Good First Issue
and removed
👋 Good First Issue
labels
Dec 16, 2021
2 tasks
Just a thought: for the logic returning the var count = 0
testNetworkTransport.register(query) { query ->
count++
when (count) {
1 -> {
hero = humanHero {
name = "Luke"
}
}
2 -> {
hero = humanHero {
name = "Han"
}
}
} |
Fixed in 3.1.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now that we have test builders, we can use them to make writing tests easier. The testing can happen at 2 levels:
The
NetworkTransport
interface is relatively simple:TestNetworkTransport
can maintain aMutableMap<Operation, ApolloResponse>
so that it responds with the pre-recordedApolloResponse
for the given operation (that would be build from the test builders).Building a test client:
Ideally, the API would look like:
The
registerOperation {}
part is the hard part because there's no simple generic way to get theHeroQuery_TestBuilder
from aHeroQuery
reified type parameter. We might be able to use some compiler plugin magic like kotlinx.serialization but that adds a new component into the equation.Another solution might be to have a global registry of
_TestBuilder
keyed byKClass
but even there I'm not sure how to retrieve them without reflection, which sounds like it's doable on the JVM but not always desired and not possible at all on MPPThe text was updated successfully, but these errors were encountered: