Unit testing private methods and using mock objects
The internet is flooded with pages saying that we should not write unit
test cases for a private method. But I am not sure is it correct to say
that we should completely ignore the private methods for unit test cases?
I know they would be eventually tested if we test the main public method.
But imagine my method which hits the database and populates the object
from the dataset is contained, in a private method. If I want to use mock
for my database I would have to write a unit test case for this method
which would force me to make it public. How do I overcome such situations?
No comments:
Post a Comment