Java: remove mention of abstract classes from qhelp

This commit is contained in:
Jami Cogswell
2025-03-23 18:30:39 -04:00
parent dca4c58b29
commit 0f002624d6
2 changed files with 5 additions and 14 deletions

View File

@@ -37,7 +37,7 @@ public class IntegerOperationTest {
## Implementation Notes
This rule is focused on missing `@Nested` annotations on non-static nested (inner) test classes. Static nested test classes and abstract nested test classes should not be annotated with `@Nested`. As a result, the absence of a `@Nested` annotation on such classes is compliant. Identifying incorrect application of a `@Nested` annotation to static and abstract classes is out of scope for this rule.
This rule is focused on missing `@Nested` annotations on non-static nested (inner) test classes. Static nested test classes should not be annotated with `@Nested`. As a result, the absence of a `@Nested` annotation on such classes is compliant. Identifying incorrect application of a `@Nested` annotation to static nested classes is out of scope for this rule.
## References

View File

@@ -87,29 +87,20 @@ public class AnnotationTest {
}
}
// COMPLIANT: Invalid to use `@Nested` on an abstract class, but
// this matter is out of scope (see QHelp Implementation Notes)
@Nested
public abstract class Test8 {
@Test
public void test() {
}
}
interface Test9 {
interface Test8 {
}
public void f() {
// COMPLIANT: anonymous classes are not considered as inner test
// classes by JUnit and therefore don't need `@Nested`
new Test9() {
new Test8() {
@Test
public void test() {
}
};
// COMPLIANT: local classes are not considered as inner test
// classes by JUnit and therefore don't need `@Nested`
class Test10 {
class Test9 {
@Test
void test() {
}
@@ -118,7 +109,7 @@ public class AnnotationTest {
// COMPLIANT: private classes are not considered as inner test
// classes by JUnit and therefore don't need `@Nested`
private class Test11 {
private class Test10 {
@Test
public void test() {
}