GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@UncleOwen UncleOwen commented May 14, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Describe the PR

Fixes JUnit5TestShouldBePackagePrivate by converting it from XPath to Java. That allows us to use the infrastructure introduced in #6604

Related issues

  • Fix [java] JUnit5TestShouldBePackagePrivate is not applied when @Test method is only present in parent class #5477

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.

All reactions
@UncleOwen
UncleOwen force-pushed the issue-5477-JUnit5TestShouldBePackagePrivate-is-not-applied-when-@Test-method-is-only-present-in-parent-class branch from a9b1154 to 0564a30 Compare May 14, 2026 18:40
@pmd-actions-helper

pmd-actions-helper Bot commented May 14, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

UncleOwen added a commit to UncleOwen/pmd that referenced this pull request May 15, 2026
@UncleOwen
[doc] Update release notes (pmd#5477, pmd#6680)
62339ea
UncleOwen added a commit to UncleOwen/pmd that referenced this pull request May 15, 2026
@UncleOwen
[doc] Update release notes (pmd#5477, pmd#6680)
3a209b0
@UncleOwen
UncleOwen force-pushed the issue-5477-JUnit5TestShouldBePackagePrivate-is-not-applied-when-@Test-method-is-only-present-in-parent-class branch 2 times, most recently from ff990e0 to 1d12872 Compare May 17, 2026 23:15
UncleOwen added 4 commits May 21, 2026 17:43
@UncleOwen
rename package junit5testnoprivatemodifier.ParentWithTest to rulesfor…
4244201
…tests.Junit5ParentWithTest

... because I plan to use it in tests for different rules
@UncleOwen
Fix pmd#5477:
d52e351
* Convert JUnit5TestShouldBePackagePrivateRule from XPath to Java
* Use new TestFrameworksUtil.isJUnit5Class() to make the rule aware of
superclasses
@UncleOwen
Add unit tests for TestFrameworksUtilTest.isJUnit5Class()
2fb6e00
@UncleOwen
[doc] Update release notes (pmd#5477, pmd#6680)
9c0c203
@UncleOwen
UncleOwen force-pushed the issue-5477-JUnit5TestShouldBePackagePrivate-is-not-applied-when-@Test-method-is-only-present-in-parent-class branch from 1d12872 to 9c0c203 Compare May 21, 2026 15:45
@UncleOwen
UncleOwen requested a review from zbynek May 21, 2026 16:01
@zbynek

zbynek commented May 21, 2026

Copy link
Copy Markdown
Contributor

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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@UncleOwen

UncleOwen commented May 21, 2026

Copy link
Copy Markdown
Member Author

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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zbynek

zbynek commented May 21, 2026

Copy link
Copy Markdown
Contributor

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.).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@UncleOwen

UncleOwen commented May 21, 2026

Copy link
Copy Markdown
Member Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@UncleOwen

UncleOwen commented May 22, 2026

Copy link
Copy Markdown
Member Author

I've added an issue for #6682. This PR is for an existing rule. Can we treat those two issues separately?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

zbynek
zbynek approved these changes May 22, 2026
View reviewed changes
@UncleOwen
UncleOwen merged commit 5db914f into pmd:main May 22, 2026
11 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@UncleOwen UncleOwen added this to the 7.25.0 milestone May 22, 2026
@UncleOwen
UncleOwen deleted the issue-5477-JUnit5TestShouldBePackagePrivate-is-not-applied-when-@Test-method-is-only-present-in-parent-class branch May 22, 2026 17:51
@adangel adangel mentioned this pull request May 28, 2026
chore: Fix pmd test setup #6728
Merged
4 tasks
UncleOwen added a commit to UncleOwen/pmd that referenced this pull request Jun 23, 2026
@UncleOwen
[java] Fix pmd#5011: TestClassWithoutTestCases
f189164
* 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 UncleOwen mentioned this pull request Jun 23, 2026
[java] Fix #5011: Fix FP in TestClassWithoutTestCases when the only tests are in a superclass #6809
Merged
3 tasks done
UncleOwen added a commit to UncleOwen/pmd that referenced this pull request Jun 23, 2026
@UncleOwen
[java] Fix pmd#5011: TestClassWithoutTestCases
1089f52
* 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
@UncleOwen
[java] Fix pmd#5011: TestClassWithoutTestCases
884e3b6
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@zbynek zbynek zbynek approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

7.25.0

Development

Successfully merging this pull request may close these issues.

[java] JUnit5TestShouldBePackagePrivate is not applied when @Test method is only present in parent class

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@UncleOwen @zbynek
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.