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 #5011: Fix FP in TestClassWithoutTestCases when the only tests are in a superclass by UncleOwen · Pull Request #6809 · pmd/pmd

Conversation

@UncleOwen

@UncleOwen UncleOwen commented Jun 23, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Describe the PR

  • Split TestFrameworksUtil.isXXXClass into hasXXXTests and isConcreteToplevelClass
  • These methods automatically supports superclasses because of the work done in previous PRs ([java] Fix #3288: New rule JUnit5TestNoPrivateModifierRule #6604, [java] Fix #5477: JUnit5TestShouldBePackagePrivate is not applied when @Test method is only present in parent class #6680, [java] Fix #4350: Fix ClassNamingConventions by teaching TestFrameworkUtil about type resolution #6689, [java] Fix #2846: New Rule: WrongTestAnnotation #6735, [java] Fix #6736: Add JTypeMirror.streamClasses() #6738)
  • Use these methods in TestClassWithoutTestCasesRule

Related issues

  • Fix [java] TestClassWithoutTestCases: False positive for test classes extending a class with tests (in nested classes) #5011

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
@pmd-actions-helper

pmd-actions-helper Bot commented Jun 23, 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 0 new violations, 0 new errors and 0 new configuration errors,
removes 137 violations, 0 errors and 0 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-06-29 06:44:16+00:00 for e06a95c)

All reactions

Sorry, something went wrong.

Uh oh!

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

@UncleOwen
UncleOwen marked this pull request as draft June 23, 2026 18:31
@UncleOwen
UncleOwen force-pushed the issue-5011-TestClassWithoutTestCases-false-positive-for-test-classes-extending-a-class-with-tests branch from ac644b2 to 20d9796 Compare June 23, 2026 19:01
@UncleOwen
UncleOwen marked this pull request as ready for review June 23, 2026 19:23
UncleOwen added 2 commits June 23, 2026 21:57
@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
@UncleOwen
[docs] Update release notes
b7aba70
@UncleOwen
UncleOwen force-pushed the issue-5011-TestClassWithoutTestCases-false-positive-for-test-classes-extending-a-class-with-tests branch from 20d9796 to b7aba70 Compare June 23, 2026 19:57
@UncleOwen
Add JUnit3 test case without warning
4b1f9e2
@UncleOwen UncleOwen changed the title [java] Fix #5011: Fix FP in TestClassWithoutTestCases when extending a class with tests [java] Fix #5011: Fix FP in TestClassWithoutTestCases when the only tests are in a superclass Jun 24, 2026
lukasgraef
lukasgraef reviewed Jun 28, 2026
View reviewed changes
Comment thread pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/internal/TestFrameworksUtil.java

@lukasgraef lukasgraef Jun 28, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think it would be good to also have dedicated unit tests in TestFrameworksUtilTest for the added hasJUnit[3-5]Tests and hasTestNGTests methods.

Apart from that, implementation and regression tester report look good.

Sorry, something went wrong.

Uh oh!

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

All reactions

@adangel adangel Jun 29, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do this with a separate PR for the next version.

Sorry, something went wrong.

Uh oh!

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

All reactions
@adangel adangel added this to the 7.27.0 milestone Jun 29, 2026
adangel
adangel reviewed Jun 29, 2026
View reviewed changes
Comment thread docs/pages/release_notes.md Resolved

Uh oh!

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

@adangel
Apply suggestion from @adangel
e06a95c
@adangel adangel modified the milestones: 7.27.0, 7.26.0 Jun 29, 2026
@adangel
adangel merged commit 9733420 into pmd:main Jun 29, 2026
9 checks passed

Uh oh!

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

@UncleOwen
UncleOwen deleted the issue-5011-TestClassWithoutTestCases-false-positive-for-test-classes-extending-a-class-with-tests branch June 29, 2026 08:39
@UncleOwen UncleOwen mentioned this pull request Jul 1, 2026
[java] Follow-up on #6809: Add tests #6838
Merged
3 tasks done
UncleOwen added a commit that referenced this pull request Jul 2, 2026
@UncleOwen
[java] Follow-up on #6809: Add tests (#6838)
e30a701
Add tests for...

* isTestClass
* hasJUnit4Tests
* hasJUnit5Tests
* hasTestNGTests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@adangel adangel adangel left review comments
@lukasgraef lukasgraef lukasgraef left review comments

Uh oh!

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

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

7.26.0

Development

Successfully merging this pull request may close these issues.

[java] TestClassWithoutTestCases: False positive for test classes extending a class with tests (in nested classes)

Uh oh!

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

3 participants

@UncleOwen @adangel @lukasgraef
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.