Remove unnecessary 'public' modifier from JUnit 5 test methods and classes#7649
Open
Vest wants to merge 1 commit into
Open
Remove unnecessary 'public' modifier from JUnit 5 test methods and classes#7649Vest wants to merge 1 commit into
Vest wants to merge 1 commit into
Conversation
…asses Sonar rule S5786 flags 'public' as redundant on JUnit 5 test/lifecycle methods and on concrete test class declarations, since the JUnit 5 platform discovers tests by annotation, not visibility. 903 concrete test classes updated across PCGen-base, PCGen-Formula, and the main code module. The script preserved: - @OverRide methods (visibility must not narrow the parent) - abstract base test classes (may be subclassed across packages) - helper/mock classes with no @test annotations (used across packages) Test count unchanged: 18,490 before and after.
Contributor
Author
|
Since we use JUnit 6, I think, we must be modern - all tests don't need "public" anymore (thanks to Sonar). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
publicmodifier from@Test,@ParameterizedTest,@BeforeEach,@AfterEach,@BeforeAll, and@AfterAllmethods across all test source setspublicfrom top-level concrete test class declarationsJUnit 5 discovers tests by annotation, not by visibility —
publicon test methods and classes is noise, not a requirement.Scope: 903 files changed in
PCGen-base,PCGen-Formula, and the maincodemodule (test, testcommon, slowtest, itest source sets).Preserved (not changed):
@Overridemethods — visibility must not narrow the parent's declarationabstractbase test classes — may be subclassed from other packages@Testannotations — used across packagesTest plan
./gradlew :PCGen-base:test :PCGen-Formula:test testpasses