A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/4503 below:

false negative with TestNG · Issue #4503 · pmd/pmd · GitHub

Affects PMD Version:7.0.0-rc1

Rule: JUnitTestsShouldIncludeAssert

Please provide the rule name and a link to the rule documentation:
https://docs.pmd-code.org/latest/pmd_rules_java_bestpractices.html#junittestsshouldincludeassert

Description:
The first code sample uses the annotations org.testng.annotations.*, and the second one uses org.junit.*. The analysis results of the two cases should be equivalent because these annotations are equivalent. However, PMD reports a warning in the second sample and no warnings in the first sample. PMD should report a warning in Case 1 like Case 2.

Code Sample demonstrating the issue:
Case 1

import org.testng.annotations.Test;
import org.testng.annotations.AfterClass;
public class A {
  @AfterClass
  @Test
  void test() {}  // report no warning
}

Case 2

import org.junit.jupiter.api.Test;
import org.junit.AfterClass;
public class B {
    @AfterClass
    @Test
    void test() {}  // report a warning
}

Expected outcome: The analysis results of the two classes should be the same and both should be reported a violation.

PMD reports no violation in the first class, but that's wrong. That's a false negative. PMD should treat testng like junit.

Running PMD through: CLI


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4