Skip to content

[java] Fix #5011: Fix FP in TestClassWithoutTestCases when the only tests are in a superclass - #6809

Merged
adangel merged 4 commits into
pmd:mainfrom
UncleOwen:issue-5011-TestClassWithoutTestCases-false-positive-for-test-classes-extending-a-class-with-tests
Jun 29, 2026
Merged

adangel merged 4 commits into
pmd:mainfrom
UncleOwen:issue-5011-TestClassWithoutTestCases-false-positive-for-test-classes-extending-a-class-with-tests

Conversation

@UncleOwen

@UncleOwen UncleOwen commented Jun 23, 2026 •

Copy link
Copy Markdown
Member

Describe the PR

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)

@pmd-actions-helper

pmd-actions-helper Bot commented Jun 23, 2026 •

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)

@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
* 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
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 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

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

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.

@adangel adangel added this to the 7.27.0 milestone Jun 29, 2026
Comment thread docs/pages/release_notes.md Resolved
@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
@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
3 tasks done
UncleOwen added a commit that referenced this pull request Jul 2, 2026
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

Labels

None yet

Projects

None yet

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)

3 participants