Skip to content

Commit eb746f5

Browse files
sachin29augpivovarit
authored andcommitted
BAEL-6839: Updated pmd unit tests rule - Allow tests ending with "jmhTest" and disallow ones ending with "Tests" (eugenp#4411)
* BAEL-6839: Updated the unit tests convention pmd rule - Don't allow unit tests ending with "Tests" and allow the ones ending with "jmhTest" ("*jmhTest" are autogenerated) * fixed formatting issue - Replaced tabs with spaces
1 parent 2e68341 commit eb746f5

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

custom-pmd-0.0.1.jar

23 Bytes
Binary file not shown.

custom-pmd/src/main/java/org/baeldung/pmd/UnitTestNamingConventionRule.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@ public class UnitTestNamingConventionRule extends AbstractJavaRule {
1414
"ManualTest",
1515
"JdbcTest",
1616
"LiveTest",
17-
"UnitTest");
17+
"UnitTest",
18+
"jmhTest");
1819

1920
public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
2021
String className = node.getImage();
2122
Objects.requireNonNull(className);
2223

23-
if (className.endsWith("Test") || className.endsWith("Tests")) {
24-
if (allowedEndings.stream()
25-
.noneMatch(className::endsWith)) {
26-
addViolation(data, node);
27-
}
24+
if (className.endsWith("Tests")
25+
|| (className.endsWith("Test") && allowedEndings.stream().noneMatch(className::endsWith))) {
26+
addViolation(data, node);
2827
}
2928

3029
return data;

0 commit comments

Comments
 (0)