3 ms·
> probably maintaining at minimum two implementations. Manual TDD (not using a mock framework) practically requires dependency injection and thus interfaces[1]
by User23 4y ago
> probably maintaining at minimum two implementations.
Manual TDD (not using a mock framework) practically requires dependency injection and thus interfaces[1] and a minimum of two implementations for each: the real one that does the work, and the one or more with minimal functionality that are passed in to other components when they're doing their own unit tests. Sometimes it even makes sense to have more than one test implementation depending on the needs of the various components that need to test against that interface. And in my experience that does act as a forcing function for making swapping out an implementation trivial. Or, as I prefer to call it, properly separating concerns.
[1] Or I suppose one could use an abstract class, but I've found interfaces cleaner.