mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
treat classes with before/after methods as test classes for bad declared exceptions (IDEA-112537)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,4 +35,11 @@ public abstract class TestFrameworks {
|
||||
|
||||
@Nullable
|
||||
public abstract PsiMethod findSetUpMethod(PsiClass psiClass);
|
||||
|
||||
@Nullable
|
||||
public abstract PsiMethod findTearDownMethod(PsiClass psiClass);
|
||||
|
||||
public boolean isTestOrConfig(PsiClass psiClass) {
|
||||
return isTestClass(psiClass) || findTearDownMethod(psiClass) != null || findTearDownMethod(psiClass) != null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -76,4 +76,19 @@ public class TestFrameworksImpl extends TestFrameworks {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public PsiMethod findTearDownMethod(final PsiClass psiClass) {
|
||||
final TestFramework[] testFrameworks = Extensions.getExtensions(TestFramework.EXTENSION_NAME);
|
||||
for (TestFramework framework : testFrameworks) {
|
||||
if (framework.isTestClass(psiClass)) {
|
||||
final PsiMethod setUpMethod = (PsiMethod)framework.findTearDownMethod(psiClass);
|
||||
if (setUpMethod != null) {
|
||||
return setUpMethod;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+2
-4
@@ -133,10 +133,8 @@ public class BadExceptionDeclaredInspection extends BaseInspection {
|
||||
super.visitMethod(method);
|
||||
if (ignoreTestCases) {
|
||||
final PsiClass containingClass = method.getContainingClass();
|
||||
if (containingClass != null && TestFrameworks.getInstance().isTestClass(containingClass)) {
|
||||
return;
|
||||
}
|
||||
if (TestUtils.isJUnitTestMethod(method)) {
|
||||
final TestFrameworks testFrameworks = TestFrameworks.getInstance();
|
||||
if (containingClass != null && testFrameworks.isTestOrConfig(containingClass)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user