Skip to content

[java] JUnitTestsShouldIncludeAssert: False positive with assert in lambda #4272

@koalalam

Description

@koalalam

Affects PMD Version:

6.52.0+
7.0.0

JDK version: 17

Rule:

JUnitTestsShouldIncludeAssert

https://pmd.sourceforge.io/pmd-6.52.0/pmd_rules_java_bestpractices.html#junittestsshouldincludeassert

Description:

Code Sample demonstrating the issue:

   CompletionStage<Object> future = ...;
   future.whenComplete(
        (data, exception) -> {
          assertNotNull(data, "Data shouldn't be null"); 
        });

Expected outcome:

PMD recognizes "assertNotNull".

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-positivePMD flags a piece of code that is not problematic

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions