================================================================================ HOW TO TEST PRIVATE METHODS? ================================================================================ Date: 2023-10-20 Tags: testing, tdd, software-design, clean-code URL: https://chemaclass.com/blog/how-to-test-private-methods/ -------------------------------------------------------------------------------- From time to time I have had to face this question: how to test private methods? I have put together in an article the techniques that I usually use. This is a question that I have encountered with some frequency for a long time. So I thought I would put together my thoughts on the subject here. SHORT ANSWER -------------------------------------------------------------------------------- Never. LONG ANSWER -------------------------------------------------------------------------------- Never ever. --- WHAT IF...? -------------------------------------------------------------------------------- If you really want to test a private method, consider extracting that private method logic into a separate class, and write a unit test for that class' behavior. | For this one, I was inspired by Fran Iglesias' original post (https://franiglesias.github.io/test-private-methods/). ================================================================================