Affects PMD Version: 6.24.0
Rule: MethodNamingConventions
Description:
The PMD does not use the junit5TestPattern rule for tests annotated with org.junit.jupiter.params.ParameterizedTest.
Code Sample demonstrating the issue:
pmd.xml:
<rule ref="category/java/codestyle.xml/MethodNamingConventions">
<properties>
<property name="methodPattern" value="[a-z][a-zA-Z0-9]*"/>
<property name="staticPattern" value="[a-z][a-zA-Z0-9]*"/>
<property name="nativePattern" value="[a-z][a-zA-Z0-9]*"/>
<property name="junit3TestPattern"
value="test_[a-z][a-zA-Z0-9]*(_with(out)?[A-Z0-9][a-zA-Z0-9]*)?_should[A-Z0-9][a-zA-Z0-9]*"/>
<property name="junit4TestPattern"
value="test_[a-z][a-zA-Z0-9]*(_with(out)?[A-Z0-9][a-zA-Z0-9]*)?_should[A-Z0-9][a-zA-Z0-9]*"/>
<property name="junit5TestPattern"
value="test_[a-z][a-zA-Z0-9]*(_with(out)?[A-Z0-9][a-zA-Z0-9]*)?_should[A-Z0-9][a-zA-Z0-9]*"/>
</properties>
</rule>
Test code:
@ParameterizedTest
@ValueSource(strings = { "FEMALE", "MALE" })
public void test_fromValue_withGenderValues_shouldReturnEnumType(final String value) {
assertNotNull(Gender.fromValue(value));
}
Problem:
The instance method name 'test_fromValue_withGenderValues_shouldReturnEnumType' doesn't match '[a-z][a-zA-Z0-9]*'
Expected outcome:
- Does PMD report a violation, where there shouldn't be one? -> false-positive
Running PMD through: Gradle
Affects PMD Version: 6.24.0
Rule: MethodNamingConventions
Description:
The PMD does not use the
junit5TestPatternrule for tests annotated withorg.junit.jupiter.params.ParameterizedTest.Code Sample demonstrating the issue:
pmd.xml:
Test code:
Problem:
Expected outcome:
Running PMD through: Gradle