A RetroSearch Logo

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

Search Query:

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

[java] MethodNamingConventions junit5TestPattern does not detect parameterized tests · Issue #3403 · pmd/pmd · GitHub

Affects PMD Version:
maven-pmd-plugin: 3.14.0

Rule:
ref="category/java/codestyle.xml/MethodNamingConventions"

https://pmd.github.io/latest/pmd_rules_java_codestyle.html#methodnamingconventions

Description:

The rule for junit5 method names misinterprets parameterized tests as normal methods and therefore applies the wrong regex filter.

<rule ref="category/java/codestyle.xml/MethodNamingConventions">
	<properties>
        <property name="methodPattern" value="[a-z][a-zA-Z0-9]*" />
    	<property name="junit5TestPattern" value="[a-zA-Z0-9_]*" />
	</properties>
</rule>

Code Sample demonstrating the issue:

@ParameterizedTest(name = "{0}")
@ValueSource(...)
public void equals_false(...) {
	assertFalse(...);
}

the method will not be detected as unit test and therefore the 'methodPattern' from the rule gets applied. But actually this is a junit5 test and the 'junit5TestPattern' should be applied.


**Running PMD through:** *[Maven | Eclipse PMD Plugin]*

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