Affects PMD Version:
6.53.0
7.0.0
Rule:
ClassNamingConventions
Description:
If a class containing no @Test methods inherits from an abstract class that does have @Test methods it's not regarded as a test class itself and bypasses the testClassPattern check as part of ClassNamingConventions
Code Sample demonstrating the issue:
package com.github.screamingfrog;
class Derived extends AbstractUnitTest
{
// Not detected as a Test class so ClassNamingConventions for testClassPattern not applied
@Override
int getVal()
{
return 0;
}
}
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
abstract public class AbstractUnitTest
{
abstract int getVal();
@Test
public void testApp()
{
assertEquals(1, getVal());
}
}
Expected outcome:
PMD should report this as a violation.
Running PMD through: [ Maven ]
I've created a stand along maven project to reproduce the issues here:
https://github.com/screamingfrog/hello-world-cli/tree/pmd-testclasspattern-issue
Affects PMD Version:
6.53.0
7.0.0
Rule:
ClassNamingConventions
Description:
If a class containing no
@Testmethods inherits from an abstract class that does have@Testmethods it's not regarded as a test class itself and bypasses thetestClassPatterncheck as part ofClassNamingConventionsCode Sample demonstrating the issue:
Expected outcome:
PMD should report this as a violation.
Running PMD through: [ Maven ]
I've created a stand along maven project to reproduce the issues here:
https://github.com/screamingfrog/hello-world-cli/tree/pmd-testclasspattern-issue