Skip to content

[java] UnitTestShouldIncludeAssert: False positive with SoftAssertionsExtension on parent/grandparent classes#6432

Merged
adangel merged 5 commits intopmd:mainfrom
kaliy:support-nested-classes-for-missing-assertions
Feb 22, 2026
Merged

[java] UnitTestShouldIncludeAssert: False positive with SoftAssertionsExtension on parent/grandparent classes#6432
adangel merged 5 commits intopmd:mainfrom
kaliy:support-nested-classes-for-missing-assertions

Conversation

@kaliy
Copy link
Contributor

@kaliy kaliy commented Jan 29, 2026

Describe the PR

This PR fixes a false postive in the UnitTestShouldIncludeAssert rule when using AssertJ's SoftAssertionsExtension with nested test classes.

Previously, the rule only recgnized @ExtendWith(SoftAssertionsExtension.class) when it was declared on the same class as the test method. But extension applies to nested classes too. PMD was reporting missing assertions when the extension was declared on a parent or grandparent class.

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)
  • Added (in-code) documentation (if needed)

@kaliy kaliy changed the title [java] UnitTestShouldIncludeAssert - fix false positive with SoftAssertionsExtension on parent classes [java] UnitTestShouldIncludeAssert: False positive with SoftAssertionsExtension on parent/grandparent classes Jan 29, 2026
@adangel adangel modified the milestones: 7.23.0, 7.22.0 Feb 22, 2026
@pmd-actions-helper
Copy link
Contributor

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.

Regression Tester Report

(comment created at 2026-02-22 17:27:41+00:00 for b1876d7)

Copy link
Member

@adangel adangel left a comment

Choose a reason for hiding this comment

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

Thanks!

@adangel adangel merged commit 2d7ff1a into pmd:main Feb 22, 2026
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] UnitTestShouldIncludeAssert: False positive with SoftAssertionsExtension on parent/grandparent classes

2 participants