Testing Without Mocks: A Pattern Language
jamesshore.com
jamesshore.com
For instance in Android we've Activities/Fragments (and less commonly Views) as the entry points to the application code. From there we might have [View Models](https://developer.android.com/topic/libraries/architecture/v...) and External API clients that are clearly infrastructure.
From what I've seen it is common to call the External API clients from ViewModels directly. (This is so we can test more logic outside of Android runtime, AFAIK.)
If I get the layers you've described we should instead let Activity/Fragment ask the ViewModel for some data and then use it to call the External API, correct?
I think in this context you're using `interface` in the way that C# uses it: a point of abstraction and indirection.
I think you aren't using it in the API sense: the external surface of a thing.
If that's correct, you may want to clarify your wording. Perhaps "abstract interface".
Is there sample code illustrating the pattern language?
One way I approach this is "a bug will only cause one test to fail _at that level of abstraction_".
Simulators fit right where you have Nullable Infrastructure. Having a null object and a real object, instead of a single object with both null and real behaviors is how I'd normally organize things. I write my Focused Integration tests so they can be run against both the real and the simulator, to ensure that they both agree on the contract. And just like the Nullable Infrastructure, I can use the simulator in tests.
However, the real with with Ports-and-Adapters isn't the simulators (even though everyone notices that first). It's the way a good Port abstraction lets you organize your code well, writing it in terms that make sense in your domain, instead of in terms of the dependency.
This is worth exploring further.
That's why the null code is inside the infrastructure, instead of using the classic Null Object pattern. It's also a major difference between it and classic test doubles. And perhaps your simulators?