We often write code in a similar way if we need to pass in values in for testing — however by far not always, and not when we can get away without having to do that. The question is why should this convention be imposed by a foundational library?
One may like this kind of approach for testing their particular project (and I do, for some of my projects). How does it follow from that that this approach should pervade throughout the rest of the ecosystem?
On another axis, when I am testing my projects, I choose what I need to mock. Why should a foundational library pervasively force me to mock a larger set of entities than I need?
I can often get away with passing in mock entities directly to the functions of an inner module under test, for its unit tests. This allows me to keep the outer modules of the project cleaner, if I don’t need to mock for the kind of integration tests I am writing. Why should a foundational library force me to thread mock values all the way through the entire program, and pass them in at the main
function? If I do need to do pass in values through the outer modules, that’s fine, but why should I and everyone be forced to?
Why should the extra cost of doing this be spread to all other users and projects, and for me, to more entities than I need treated in this way?