I suppose @VisibleForTesting may be a useful tool in some circumstances, so thank you! However, in this particular case (have you ever read Khorikov's book on unit testing?) I would tend to say that the code to be tested has poor separation of concerns: I would usually indeed have some kind of Formatter class (or extension function) and test that, and let the presentation of the message (here, to the console) be done by another class. After all, as developers we usually have specific classes for IO (like controllers, or repositories, or filewriters), so separating the possibly complex and hence useful-to-test business logic from the 'plumbing' of IO would make sense.
Your playlist abou tests seems very cool, I am goin to be watching ot soon.
Helpful, Thank you
Informative.
Thanks, great help. Will use this
Glad it was helpful!
Thanks for the video, one question, will this add line coverage to the private function?
Yes, for me its adding the coverage
I suppose @VisibleForTesting may be a useful tool in some circumstances, so thank you! However, in this particular case (have you ever read Khorikov's book on unit testing?) I would tend to say that the code to be tested has poor separation of concerns: I would usually indeed have some kind of Formatter class (or extension function) and test that, and let the presentation of the message (here, to the console) be done by another class. After all, as developers we usually have specific classes for IO (like controllers, or repositories, or filewriters), so separating the possibly complex and hence useful-to-test business logic from the 'plumbing' of IO would make sense.
Yeep exactly, this is just a simple example that would help me demonstrate my point and the way to achieve private function testing WHEN needed.