Re:Write tests. Not too many. Mostly integration
by afarrell on Friday October 27, 2017 @06:49AM
(#15567185)
> the number of tests would explode exponentially with the number of branch conditions to handle all the corner cases
Then wouldn't you want to write something that was able to iterate through those edge-case interactions and ensure they are correct?
Re:Write tests. Not too many. Mostly integration
by alien_at_work on Friday October 27, 2017 @01:48PM
(#15570637)
I'm trying to imagine what on earth your private methods can be doing that wouldn't be affected by the public interface.
There should be no situation where the same exact call in the public interface could take multiple different paths in the private method. The only thing I can think of that could make that happen would be some dependancy, which should be mocked at the top level to control these cases.
As for the smell, sometimes things are irreducibly complex. Some things in this world do require tedious book keeping. All the refactoring in the world cannot change the degrees of freedom of some problems.
Tests on consumers should not test branches of subordinate units. If you did this then the number of tests would explode exponentially with the number of branch conditions to handle all the corner cases. If a private unit produces a list of objects, but has special cases for some values of its argument, test those branches to verify it always produces the correct list. Then just make sure each caller does the correct thing with the list of objects. That is the purpose of separation of concerns: the consumer does not need to know that some values were special.