diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/junit/SuperTearDownInFinallyInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/junit/SuperTearDownInFinallyInspection.java index 8bfce245a778..667c1592020c 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/junit/SuperTearDownInFinallyInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/junit/SuperTearDownInFinallyInspection.java @@ -55,7 +55,7 @@ public class SuperTearDownInFinallyInspection extends BaseInspection { return; } final PsiMethod method = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiMember.class, PsiLambdaExpression.class); - if (method == null) { + if (method == null || !method.getName().equals("tearDown")) { return; } final PsiClass containingClass = method.getContainingClass(); diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/junit/super_tear_down_in_finally/SuperTearDownInFinally.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/junit/super_tear_down_in_finally/SuperTearDownInFinally.java index 869536184627..0cd7f1f9e1cf 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/junit/super_tear_down_in_finally/SuperTearDownInFinally.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/junit/super_tear_down_in_finally/SuperTearDownInFinally.java @@ -1,17 +1,19 @@ -class SuperTearDownInFinally extends junit.framework.TestCase { +import junit.framework.TestCase; + +class SuperTearDownInFinally extends TestCase { public void tearDown() throws Exception { super.tearDown(); System.out.println(); } } -class NoProblem extends junit.framework.TestCase { +class NoProblem extends TestCase { public void tearDown() throws Exception { super.tearDown(); } } -class CalledInFinally extends junit.framework.TestCase { +class CalledInFinally extends TestCase { public void tearDown() throws Exception { try { @@ -20,4 +22,16 @@ class CalledInFinally extends junit.framework.TestCase { super.tearDown(); } } +} +class SomeTest extends TestCase { + @Override + protected void setUp() throws Exception { + try { + super.setUp(); + } + catch (Throwable t) { + super.tearDown(); // yellow code + } + } + public void test_something() {} } \ No newline at end of file