I am beginner at field TDD. Recently I have conversation with Dror Helper should I test my private methods or not. After I have talked with him and little reconsider I thing we don’t need to test private methods.
If we need to test private methods we can do this trough public methods that call those private methods.
For example if we have one public method that calls one or several other private methods like this:
public static bool LogIn(string userName, string password)
{
var user = new User(userName, password);
if (verifyThatUserIsValid(user))
{
return true;
}
else
{
return false;
}
}
private static bool verifyThatUserIsValid(User user)
{
throw new NotImplementedException();
}
So if I want to make unit tests for method verifyThatUserIsValid I can easily make unit tests for method LogIn to test that method. What do you think about this?