mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IG: don't warn on test classes annotated with @RunWith (IDEA-163266)
This commit is contained in:
+5
-1
@@ -77,7 +77,10 @@ public class TestMethodIsPublicVoidNoArgInspectionBase extends BaseInspection {
|
||||
if (!TestUtils.isJUnit3TestMethod(method) && !TestUtils.isJUnit4TestMethod(method)) {
|
||||
return;
|
||||
}
|
||||
final PsiType returnType = method.getReturnType();
|
||||
final PsiClass containingClass = method.getContainingClass();
|
||||
if (containingClass == null || AnnotationUtil.isAnnotated(containingClass, TestUtils.RUN_WITH, true)) {
|
||||
return;
|
||||
}
|
||||
final PsiParameterList parameterList = method.getParameterList();
|
||||
if (method.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
registerMethodError(method, Problem.STATIC, method);
|
||||
@@ -97,6 +100,7 @@ public class TestMethodIsPublicVoidNoArgInspectionBase extends BaseInspection {
|
||||
return;
|
||||
}
|
||||
}
|
||||
final PsiType returnType = method.getReturnType();
|
||||
if (!PsiType.VOID.equals(returnType) || !method.hasModifierProperty(PsiModifier.PUBLIC)) {
|
||||
registerMethodError(method, Problem.NOT_PUBLIC_VOID, method);
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
|
||||
@org.junit.runner.RunWith(org.junit.runner.Runner.class)
|
||||
class JUnit4RunWith {
|
||||
|
||||
@org.junit.Test
|
||||
public int testMe(int i) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
+16
-3
@@ -26,6 +26,7 @@ public class TestMethodIsPublicVoidNoArgInspectionTest extends LightInspectionTe
|
||||
|
||||
public void testJUnit3TestMethodIsPublicVoidNoArg() { doTest(); }
|
||||
public void testJUnit4TestMethodIsPublicVoidNoArg() { doTest(); }
|
||||
public void testJUnit4RunWith() { doTest(); }
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -40,11 +41,23 @@ public class TestMethodIsPublicVoidNoArgInspectionTest extends LightInspectionTe
|
||||
"public @interface Test {\n" +
|
||||
" java.lang.Class<? extends java.lang.Throwable> expected() default org.junit.Test.None.class;" +
|
||||
"}",
|
||||
|
||||
"package org.junit.runner;" +
|
||||
"@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)\n" +
|
||||
"@java.lang.annotation.Target({java.lang.annotation.ElementType.TYPE})\n" +
|
||||
"@java.lang.annotation.Inherited\n" +
|
||||
"public @interface RunWith {\n" +
|
||||
" Class<? extends Runner> value();\n" +
|
||||
"}",
|
||||
|
||||
"package org.junit.runner;" +
|
||||
"public abstract class Runner {}",
|
||||
|
||||
"package junit.framework;" +
|
||||
"public abstract class TestCase {}",
|
||||
|
||||
"package mockit;" +
|
||||
"@Retention(value=RUNTIME) @Target(value={FIELD,PARAMETER})" +
|
||||
"public @interface Mocked {}"};
|
||||
"package mockit;" +
|
||||
"@Retention(value=RUNTIME) @Target(value={FIELD,PARAMETER})" +
|
||||
"public @interface Mocked {}"};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user