BAEL-6839: Updated pmd unit tests rule - Allow tests ending with "jmhTest" and disallow ones ending with "Tests" (#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
This commit is contained in:
parent
2e683411e2
commit
eb746f5ac6
Binary file not shown.
@ -14,18 +14,17 @@ public class UnitTestNamingConventionRule extends AbstractJavaRule {
|
|||||||
"ManualTest",
|
"ManualTest",
|
||||||
"JdbcTest",
|
"JdbcTest",
|
||||||
"LiveTest",
|
"LiveTest",
|
||||||
"UnitTest");
|
"UnitTest",
|
||||||
|
"jmhTest");
|
||||||
|
|
||||||
public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
|
public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
|
||||||
String className = node.getImage();
|
String className = node.getImage();
|
||||||
Objects.requireNonNull(className);
|
Objects.requireNonNull(className);
|
||||||
|
|
||||||
if (className.endsWith("Test") || className.endsWith("Tests")) {
|
if (className.endsWith("Tests")
|
||||||
if (allowedEndings.stream()
|
|| (className.endsWith("Test") && allowedEndings.stream().noneMatch(className::endsWith))) {
|
||||||
.noneMatch(className::endsWith)) {
|
|
||||||
addViolation(data, node);
|
addViolation(data, node);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user