I have classes which previously had massive methods so I subdivided the work of this method into 'helper' methods.
These helper methods are declared private
to enforce encapsulation - however I want to unit test the big public methods. Is it good to unit test the helper methods too as if one of them fail the public method that calls it will also fail, and this way we can identify why it failed?
Also in order to test these using a mock object I would need to change their visibility from private to protected, is this desirable?
One way is to omit private
and put the tests in the same package. Then the tests can call the internal methods but no one else (= outside the package) can.
Also, failing internal methods should produce error messages which make it easy to fix the issue. When you put the code into production, you'll see less than the tests and you'll be under a lot of pressure to fix the issues fast. So one minute spent here will save you one hour later with your boss sitting in your neck.