Java: move original files

This commit is contained in:
Jami Cogswell
2025-03-21 11:08:10 -04:00
parent 631ccdf380
commit ccbe77eb09
7 changed files with 145 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Nested;
public class AnnotationTest {
@Nested
public class Test1 { // COMPLIANT: Inner test class has `@Nested`
@Test
public void test() {
}
}
public class Test2 { // NON_COMPLIANT: Inner test class is missing a `@Nested`
@Test
public void test() {
}
}
public class Test3 { // COMPLIANT: Since it is empty, it is not a test class
}
public class Test4 { // COMPLIANT: Since no methods have `@Test`, it is not a test class
public void f() {
}
public void g() {
}
public void h() {
}
}
public static class Test5 { // COMPLIANT: Static inner test classes don't need `@Nested`
@Test
public void test() {
}
}
@Nested
public static class Test6 { // COMPLIANT: Although invalid, this matter is out of the scope (see Implementation Details)
@Test
public void test() {
}
}
}

View File

@@ -0,0 +1 @@
| AnnotationTest.java:12:16:12:20 | Test2 | This JUnit5 inner test class lacks a @Nested annotation. |

View File

@@ -0,0 +1 @@
Likely Bugs/Frameworks/JUnit/JUnit5NonStaticInnerClassMissingNestedAnnotation.ql

View File

@@ -0,0 +1 @@
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../../stubs/junit-jupiter-api-5.2.0

View File

@@ -0,0 +1,4 @@
package org.junit.jupiter.api;
public @interface Nested {
}