Best testing practices rely on focusing on code that is visible to external parties, whether that is another class, component, project, service, or product. If you find yourself wanting to test private methods or classes, rethink your design.
exists for two purposes:
- Notify other developers that the method has been relaxed from private to package-private or protected to allow tests in the same package to access and test it. In other words: “Leave it the way it is, I meant to do this!”
- Instruct tools like Checkstyle to ignore methods when running the
VisibilityModifierCheck. It is one of the default annotations to ignore for this check.
Thanks for reading!