diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/junit/JUnit3StyleTestMethodInJUnit4ClassInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/junit/JUnit3StyleTestMethodInJUnit4ClassInspection.java index c39865049e95..848041881646 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/junit/JUnit3StyleTestMethodInJUnit4ClassInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/junit/JUnit3StyleTestMethodInJUnit4ClassInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -75,7 +75,7 @@ public class JUnit3StyleTestMethodInJUnit4ClassInspection extends BaseInspection if (!TestUtils.isRunnable(method)) { return; } - if (TestUtils.isJUnit4TestMethod(method)) { + if (TestUtils.isAnnotatedTestMethod(method)) { return; } final PsiClass containingClass = method.getContainingClass(); diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit3StyleTestMethodInJUnit4Class.html b/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit3StyleTestMethodInJUnit4Class.html index 63fca0af67b0..c765a659c6b3 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit3StyleTestMethodInJUnit4Class.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit3StyleTestMethodInJUnit4Class.html @@ -1,7 +1,7 @@
Reports JUnit 3 style test methods which are located inside a class -which does not extend the abstract JUnit 3 class TestCase and contains JUnit 4 @Test annotated methods. +which does not extend the abstract JUnit 3 class TestCase and contains JUnit 4/JUnit 5 @Test annotated methods. In addition to being confusing such test methods will not be run.diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/junit/junit3_style_test_method_in_junit4_class/SimpleJUnit5.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/junit/junit3_style_test_method_in_junit4_class/SimpleJUnit5.java new file mode 100644 index 000000000000..15375994b1df --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/junit/junit3_style_test_method_in_junit4_class/SimpleJUnit5.java @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2016 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import org.junit.jupiter.api.Test; + +public class SimpleJUnit5 { + @Test + public void testIt() { + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/junit/JUnit3StyleTestMethodInJUnit4ClassInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/junit/JUnit3StyleTestMethodInJUnit4ClassInspectionTest.java index eb7e979f81e1..768c59563c5c 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/junit/JUnit3StyleTestMethodInJUnit4ClassInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/junit/JUnit3StyleTestMethodInJUnit4ClassInspectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -26,6 +26,7 @@ public class JUnit3StyleTestMethodInJUnit4ClassInspectionTest extends LightInspe public void testJUnit3StyleTestMethodInJUnit4Class() { doTest(); } public void testBeforeAnnotationUsed() { doTest(); } + public void testSimpleJUnit5() { doTest(); } @Nullable @Override @@ -51,6 +52,14 @@ public class JUnit3StyleTestMethodInJUnit4ClassInspectionTest extends LightInspe "import java.lang.annotation.Target;" + "@Retention(RetentionPolicy.RUNTIME)" + "@Target({ElementType.METHOD})" + + "public @interface Test {}", + "package org.junit.jupiter.api;" + + "import java.lang.annotation.ElementType;" + + "import java.lang.annotation.Retention;" + + "import java.lang.annotation.RetentionPolicy;" + + "import java.lang.annotation.Target;" + + "@Retention(RetentionPolicy.RUNTIME)" + + "@Target({ElementType.METHOD})" + "public @interface Test {}" }; }