GeezerVison is showing github.com — [java] Fix #5477: JUnit5TestShouldBePackagePrivate is not applied when @Test method is only present in parent class by UncleOwen · Pull Request #6680 · pmd/pmd
Conversation
UncleOwen
commented
May 14, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Describe the PR
Fixes JUnit5TestShouldBePackagePrivate by converting it from XPath to Java. That allows us to use the infrastructure introduced in #6604
Related issues
Ready?
- Added unit tests for fixed bug/feature
- Passing all unit tests
- Complete build
./mvnw clean verify passes (checked automatically by github actions)
- [n/a] Added (in-code) documentation (if needed)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Documentation Preview
Compared to main:
This changeset changes 0 violations,
introduces 34 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 15 errors and 9 configuration errors.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.
Regression Tester Report
(comment created at 2026-05-21 16:01:36+00:00 for 9c0c203)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…tests.Junit5ParentWithTest
... because I plan to use it in tests for different rules
* Convert JUnit5TestShouldBePackagePrivateRule from XPath to Java
* Use new TestFrameworksUtil.isJUnit5Class() to make the rule aware of
superclasses
|
This introduces a couple more usages of JUnit5 in naming - should we resolve #6682 first and apply the resulting naming in this PR? Or create a quick follow-up PR to make sure the rule that was not released yet gets a future-proof name from the start?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
You're right. Adding something just to rename it days later doesn't make sense. Should I rename this to JUnitJupiterTestShouldBePackagePrivate? That's the naming scheme both of us preferred, right?
What do you mean with "a couple"? #6682 is only about rule names and properties. Were you thinking about renaming all the methods referring to junit5 as well?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
What do you mean with "a couple"?
I just meant that previously it was the name of the rule, now it's also the name of a rule class and appears in some tests (e.g. Junit5ParentWithTest ) .
For 7.25 it would IMHO make sense to rename JUnitJupiterTestShouldBePackagePrivate to JUnitJupiterTestShouldBePackagePrivate (this PR) and maybe deprecate + rename JUnit5TestShouldBePackagePrivate (another PR?) -- renaming methods should probaly wait (could break API compatibility etc.).
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Oh, right. This is an existing rule. (Shows how good I know my own PRs...)
In that case, let's not rename anything in this PR. Instead, let's create an issue for #6682 and rename all existing rules/properties at once. That way, there is no release with some rules renamed and some not.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I've added an issue for #6682. This PR is for an existing rule. Can we treat those two issues separately?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
UncleOwen
deleted the
issue-5477-JUnit5TestShouldBePackagePrivate-is-not-applied-when-@Test-method-is-only-present-in-parent-class
branch
May 22, 2026 17:51
UncleOwen
added a commit
to UncleOwen/pmd
that referenced
this pull request
Jun 23, 2026
* Split TestFrameworksUtil.isXXXClass into hasXXXTests and
isConcreteToplevelClass
* Use those for a new TestFrameworksUtil.hasTests() method.
* This method automatically supports superclasses because of the work
done in previous PRs (pmd#6604, pmd#6680, pmd#6689, pmd#6735, pmd#6738)
* Use TestFrameworksUtil.hasTests() in TestClassWithoutTestCasesRule
UncleOwen
added a commit
to UncleOwen/pmd
that referenced
this pull request
Jun 23, 2026
* Split TestFrameworksUtil.isXXXClass into hasXXXTests and
isConcreteToplevelClass
* These methods automatically supports superclasses because of the work
done in previous PRs (pmd#6604, pmd#6680, pmd#6689, pmd#6735, pmd#6738)
* Use these methods in TestClassWithoutTestCasesRule
UncleOwen
added a commit
to UncleOwen/pmd
that referenced
this pull request
Jun 23, 2026
* Split TestFrameworksUtil.isXXXClass into hasXXXTests and
isConcreteToplevelClass
* These methods automatically supports superclasses because of the work
done in previous PRs (pmd#6604, pmd#6680, pmd#6689, pmd#6735, pmd#6738)
* Use these methods in TestClassWithoutTestCasesRule
Reviewers
zbynek
zbynek approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
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.
|