4 ms·
> There is no formal definition of what a unit is or how small it should be, but it’s mostly accepted that it corresponds to an individual function of a module
by bencoder 6y ago
> There is no formal definition of what a unit is or how small it should be, but it’s mostly accepted that it corresponds to an individual function of a module (or method of an object).
And there-in lies the problem. Remove the idea that the unit is a single method/function.
I subscribe to the idea that a unit is a unit of functionality. Nothing to do with the code implementation.
Only mock where you're reaching out outside of your codebase (filesystem, network, operating system (time, for ex.))
You can still do unit tests for individual functions when you need to work on a complicated algorithm, but those functions should have no dependencies or side effects - pass in all the data you need