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.
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
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.
Possible Properties: