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: JUnit5TestNoPrivateModifier · Issue #3288 · pmd/pmd

[java] New Rule: JUnit5TestNoPrivateModifier #3288

New issue
Copy link
New issue
Copy link
Closed
#6604
Closed
[java] New Rule: JUnit5TestNoPrivateModifier#3288
#6604
Copy link
Labels
a:new-ruleProposal to add a new built-in rule
Milestone
7.25.0

Description

@adangel
adangel
opened on May 21, 2021
Issue body actions

Proposed Rule Name: JUnit5TestNoPrivateModifier

Proposed Category: Error Prone

Description:
See discussion in #3239. The rule should flag test methods / test classes, that are private, since they can't be executed by JUnit(5).

Sonar has a similar rule: https://rules.sonarsource.com/java/tag/tests/RSPEC-5810

The rule "JUnit5TestNoPrivateModifier" would probably also apply to JUnit4, so the name could also be "JUnitTestWrongModifier" (for JUnit4, private, protected and no modifier would be flagged, for JUnit5 only private modifier would be flagged).

Code Sample: This should include code, that should be flagged by the rule. If possible, the "correct" code
according to this new rule should also be demonstrated.

class MyTest { // not public, that's fine
    @Test
    private void testBad() { } // private test methods don't work
    @Test
    void testGoodJunit5() { } // package private as expected for JUnit5
    @Test
    public void testGoodJunit4() { } // public test method for JUnit4
}

Possible Properties:

  • No properties. The rule should be smart enough to distinguish between JUnit5 and JUnit4 automatically.

Activity

  1. adangel
    added
    a:new-ruleProposal to add a new built-in rule
    on May 21, 2021
  2. adangel commented on May 21, 2021

    @adangel
    adangel
    on May 21, 2021
    MemberAuthor
    More actions

    @ajeans FYI - I've separated out the other rule into its own issue.

  3. adangel
    added this to the 7.25.0 milestone on May 7, 2026
  4. adangel
    added a commit that references this issue on May 14, 2026

    [doc] Update release notes (#6604, #3288)

    eee9f7f
  5. adangel
    closed this as completedin a5c7f26on May 14, 2026
  6. adangel
    added a commit that references this issue on May 14, 2026

    [java] Fix pmd#3288: New rule JUnit5TestNoPrivateModifierRule (pmd#6604)

    This issue will close once commit a5c7f26 is merged into the 'main' branch.
    a5c7f26
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.25.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.