-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
In JUnit Jupiter, the public modifier is optional in test classes and methods.
I see test classes in JUnit, Spring projects, etc apply this no public modifier pattern.
Once I get used to this style, it feels very redundant when I encounter tests that have public all over.
I believe this is a good practice to follow.
However, in JUnit documentation, I only find this line regarding the public modifier:
Test classes, test methods, and lifecycle methods are not required to be public, but they must not be private.
It would be great if JUnit documentation mentions that leaving off the public modifier is preferred unless visibility is required. (e.g. base class shared by different packages)
I understand this is a bit of opinionated aspect, but it would be nice to mention the principle of "less is more" in the documentation.
So that, a person like me can encourage this pattern to other devs with the backup of JUnit good practice.