A RetroSearch Logo

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

Search Query:

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

[java] JUnitSpelling false-positive for JUnit5/4 tests · Issue #2477 · pmd/pmd · GitHub

Affects PMD Version:
6.23

Description:
JUnitSpelling requires some tweaks in terms of documentation and produces false positives for:

  1. JUnit4 class when it doesn't extend TestCase but has a setup method
  2. JUnit5 class when it has a setup method

Code Sample demonstrating the issue:

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class BTest {

    @BeforeEach
    void setup() {    }

    @Test
    void test() {    }
}
import org.junit.Before;
import org.junit.Test;
public class BTest {

    @Before
    void setup() {    }

    @Test
    void test() {    }
}

Running PMD through: [CLI]

I suggest two things:

  1. Do not trigger if it's a junit5 class (isJUnit5Class from AbstractJUnitRule can be used).
  2. Do not trigger if junit4 doesn't extend TestCase

WDYT?


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