void () { myFixture.addClass("package p; import org.junit.*; import org.junit.runners.*; public class Theories extends Parameterized {}"); myFixture.addClass("package p; public @interface Theory {}"); //custom annotation PsiFile file = myFixture.configureByText("A.java", """ import org.junit.Test; import org.junit.runner.RunWith; import p.Theories; import java.util.*; @RunWith(Theories.class) public class A { @Theory public void validTestMethod(int param) {} public class Foo { public void testMe() {} } } """); PsiClass aClass = ((PsiClassOwner)file).getClasses()[0]; TestFramework framework = TestFrameworks.detectFramework(aClass); assertNotNull(framework); assertTrue(framework.isTestClass(aClass)); assertTrue(framework.isTestMethod(aClass.getMethods()[0])); PsiClass innerClass = aClass.getInnerClasses()[0]; assertFalse(framework.isTestClass(innerClass)); assertFalse(framework.isTestMethod(innerClass.getMethods()[0])); }