GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [java] New Rule: WrongTestAnnotation · Issue #2846 · pmd/pmd

[java] New Rule: WrongTestAnnotation #2846

New issue
Copy link
New issue
Copy link
Closed
#6735
Closed
[java] New Rule: WrongTestAnnotation#2846
#6735
Copy link
Labels
a:new-ruleProposal to add a new built-in rule
Milestone
7.26.0

Description

@numeralnathan
numeralnathan
opened on Oct 22, 2020
Issue body actions

Proposed Rule Name: CorrectTestAnnotation

Proposed Category: Error Prone

Description:

Some projects use JUnit's @Test and other projects use TestNG's @Test. Sometimes both of these annotations are available on the classpath via dependencies. If a programmer picks the wrong one in an autocomplete popup, then they think the test case will be tested but in fact it will be ignored. Code review won't likely catch the problem since most people ignore the imports. Even if code coverage is being enforced, the programmer will struggle to figure out why their test case is not running.

Code Sample:

The following code compiles but never runs if the project is using TestNG.

import org.junit.Test;

@Test
public static void myTest()
{
}

The following code compiles but never runs if the project is using JUnit.

import org.testng.annotations.Test;

@Test
public static void myTest()
{
}

Properties:

  • framework: should be one of [JUnit | TestNG]. It could default to JUnit since that seems to be more popular.

Activity

  1. numeralnathan
    added
    a:new-ruleProposal to add a new built-in rule
    on Oct 22, 2020
  2. UncleOwen
    changed the title [-][java] Use the correct @Test annotation[/-] [+][java] New Rule: WrongTestAnnotation[/+] on May 29, 2026
  3. UncleOwen
    added 5 commits that reference this issue on May 29, 2026

    [doc] Update release notes (pmd#2846)

    be50f44

    [doc] Update release notes (pmd#2846)

    66af4b9

    [doc] Update release notes (pmd#2846)

    00135c9

    [doc] Update release notes (pmd#2846)

    53a3723

    [doc] Update release notes (pmd#2846)

    cd424ac
  4. UncleOwen
    added this to the 7.26.0 milestone on Jun 3, 2026
  5. UncleOwen
    added a commit that references this issue on Jun 3, 2026

    [java] Fix #2846: New Rule: WrongTestAnnotation (#6735)

    This issue will close once commit 2b8a33c is merged into the 'main' branch.
    2b8a33c
  6. UncleOwen
    closed this as completedin #6735on Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:new-ruleProposal to add a new built-in rule

    Type

    No type

    Projects

    No projects

      Milestone

      • 7.26.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.