Skip to content
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

Make TreehouseApp an interface #1737

Closed
wants to merge 1 commit into from

Conversation

jingwei99
Copy link

@jingwei99 jingwei99 commented Dec 11, 2023

This makes it easier to mock TreehouseApp for testing in downstream repo(s).

@JakeWharton
Copy link
Collaborator

JakeWharton commented Dec 11, 2023

I'm pretty opposed to the idea that someone could effectively mock this interface and provide suitable behavior. Mocking service types that you don't own is a pretty strong indicator of a broken test that is encoding implementation details in the test (change detector test) rather than observing visible effects.

I'd be interested in what is being tested and what the goal of the test actually is. That should tell us whether we need to provide a fake (#322) or whether the test should be running against a real implementation instead.

@jingwei99
Copy link
Author

jingwei99 commented Dec 11, 2023

I'm pretty opposed to the idea that someone could effectively mock this interface and provide suitable behavior. Mocking service types that you don't own is a pretty strong indicator of a broken test that is encoding implementation details in the test (change detector test) rather than observing visible effects.

I'd be interested in what is being tested and what the goal of the test actually is. That should tell us whether we need to provide a fake (#322) or whether the test should be running against a real implementation instead.

I ran into a case where a class depends on (has an injected) TreehouseApp needs to be tested in cash-android. In that use case, a fake will do / would be sufficient.

@JakeWharton
Copy link
Collaborator

JakeWharton commented Dec 12, 2023

I'm also skeptical as to whether a fake makes sense for this type in general (we've gone a long time without one!).

I'd be curious what the test is doing and what it expects from the fake as opposed to a real implementation on the JVM. But I guess I'll have to wait and someone else can weigh in on a near term solution to unblock.

@jingwei99
Copy link
Author

jingwei99 commented Dec 12, 2023

I'm also skeptical as to whether a fake makes sense for this type in general (we've gone a long time without one!).

I'd be curious what the test is doing and what it expects from the fake as opposed to a real implementation on the JVM. But I guess I'll have to wait and someone else can weigh in on a near term solution to unblock.

I left a DM to you (I know you are not checking DMs while you are out 🥲). I think for now a fake TreehouseApp will do, will close this PR and try to add a fake.

@colinrtwhite
Copy link
Member

@jingwei99 Probably a good discussion topic for today's treehouse meeting later today!

@jingwei99
Copy link
Author

chatted with @colinrtwhite during the meeting today, since this not urgent*, I'll close this PR, and we'll chat about it when @JakeWharton is back.

not urgent: I've found a walk-around for the need to have a fake, so this is more of a follow-up to be proactive to not to get to the same place again, other than something blocking and needs an urgent change.

@jingwei99 jingwei99 closed this Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants