use of com.intellij.testIntegration.TestFramework in project intellij-community by JetBrains.
the class TestUtils method isJUnitTestMethod.
public static boolean isJUnitTestMethod(@Nullable PsiMethod method) {
if (method == null)
return false;
final PsiClass containingClass = method.getContainingClass();
if (containingClass == null)
return false;
final TestFramework framework = TestFrameworks.detectFramework(containingClass);
return framework != null && framework.getName().startsWith("JUnit") && framework.isTestMethod(method);
}
use of com.intellij.testIntegration.TestFramework in project intellij-community by JetBrains.
the class TestUtils method isAnnotatedTestMethod.
public static boolean isAnnotatedTestMethod(@Nullable PsiMethod method) {
if (method == null)
return false;
final PsiClass containingClass = method.getContainingClass();
if (containingClass == null)
return false;
final TestFramework testFramework = TestFrameworks.detectFramework(containingClass);
if (testFramework == null)
return false;
if (testFramework.isTestMethod(method)) {
final String testFrameworkName = testFramework.getName();
return testFrameworkName.equals("JUnit4") || testFrameworkName.equals("JUnit5");
}
return false;
}
use of com.intellij.testIntegration.TestFramework in project intellij-community by JetBrains.
the class JUnit5ConverterInspection method buildVisitor.
@Override
public BaseInspectionVisitor buildVisitor() {
return new BaseInspectionVisitor() {
@Override
public void visitClass(PsiClass aClass) {
TestFramework framework = TestFrameworks.detectFramework(aClass);
if (framework == null || !"JUnit4".equals(framework.getName())) {
return;
}
if (!canBeConvertedToJUnit5(aClass))
return;
registerClassError(aClass);
}
};
}
use of com.intellij.testIntegration.TestFramework in project intellij-community by JetBrains.
the class TestDataGuessByExistingFilesUtil method getTestName.
@Nullable
private static String getTestName(@NotNull PsiMethod method) {
final PsiClass psiClass = PsiTreeUtil.getParentOfType(method, PsiClass.class);
if (psiClass == null) {
return null;
}
TestFramework framework = TestFrameworks.detectFramework(psiClass);
if (framework == null || isUtilityMethod(method, psiClass, framework)) {
return null;
}
return getTestName(method.getName());
}
use of com.intellij.testIntegration.TestFramework in project intellij-community by JetBrains.
the class JUnit5AcceptanceTest method testFrameworkDetection.
@Test
void testFrameworkDetection() {
doTest(() -> {
PsiClass aClass = myFixture.addClass("class MyTest {@org.junit.jupiter.api.Test void method() {}}");
assertNotNull(aClass);
TestFramework framework = TestFrameworks.detectFramework(aClass);
assertTrue(framework instanceof JUnit5Framework, framework.getName());
});
}
Aggregations