I am facing difficulties understanding how to well unit-test my application.
Let's say I have a public method publicMethod()
calling several private methods holding the business logic.
I learned that private methods shouldn't be unit-tested, so I need to unit-test publicMethod()
.
The problem is that my private methods at some point access the database. As I am not unit-testing the private methods, I cannot fake the database call. What I can do is fake the private method call, but then if I fake it I lose all interest of the test as the business logic isn't tested anymore.
What is the solution so I can unit-test the logic in this case?