Private methods generally shouldn't be tested directly in JUnit; instead, they should be exercised indirectly through the public methods that call them, since tests should target a class's observable behavior.
If a Calculator class has a private roundToTwoDecimals() helper used inside its public calculateTotal() method, you test it by asserting on calculateTotal()'s output rather than reflecting into the private helper directly.
A concise interview answer is
I don't test private methods directly - I test them indirectly through the public methods that use them, since tests should verify observable behavior, not implementation details. If a private method is complex enough to need its own dedicated tests, that usually means it should be extracted into its own class.
Last updated: 16 July 2026
Previous question: Can you explain how @RunWith and @Rule work in JUnit?
Next question: How do you write a test for a method with database calls in JUnit without hitting the actual database?