malformed junit 5: check non-repeatable jupiter tests only

This commit is contained in:
Anna.Kozlova
2017-10-17 17:58:55 +02:00
parent 52f1c1ee48
commit df2907a68e
3 changed files with 10 additions and 1 deletions
@@ -70,7 +70,7 @@ class JUnit5MalformedRepeatedTestInspection : AbstractBaseJavaLocalInspectionToo
"RepetitionInfo is injected for @BeforeEach/@AfterEach only, but not for " + StringUtil.getShortName(qName!!))
}
else {
if (MetaAnnotationUtil.isMetaAnnotated(method, JUnitUtil.TEST5_CONFIG_METHODS) && method.containingClass?.methods?.find { MetaAnnotationUtil.isMetaAnnotated(it, JUnitUtil.TEST5_ANNOTATIONS)} != null) {
if (MetaAnnotationUtil.isMetaAnnotated(method, JUnitUtil.TEST5_CONFIG_METHODS) && method.containingClass?.methods?.find { MetaAnnotationUtil.isMetaAnnotated(it, Annotations.NON_REPEATED_ANNOTATIONS)} != null) {
holder.registerProblem(repetitionInfoParam.nameIdentifier ?: repetitionInfoParam,
"RepetitionInfo won't be injected for @Test methods")
}
@@ -31,9 +31,13 @@ public class JUnit5MalformedParameterizedTest extends LightInspectionTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
addEnvironmentClass("package org.junit.platform.commons.annotation;\n" +
"public @interface Testable {}");
addEnvironmentClass("package org.junit.jupiter.params;\n" +
"@org.junit.platform.commons.annotation.Testable\n" +
"public @interface ParameterizedTest {}");
addEnvironmentClass("package org.junit.jupiter.api;\n" +
"@org.junit.platform.commons.annotation.Testable\n" +
"public @interface Test {}");
addEnvironmentClass("package org.junit.jupiter.api;\n" +
"public interface TestInfo {}");
@@ -31,9 +31,13 @@ public class JUnit5MalformedRepeatedTest extends LightInspectionTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
addEnvironmentClass("package org.junit.platform.commons.annotation;\n" +
"public @interface Testable {}");
addEnvironmentClass("package org.junit.jupiter.api;\n" +
"@org.junit.platform.commons.annotation.Testable\n" +
"public @interface RepeatedTest {int value(); String name() default \"\";}");
addEnvironmentClass("package org.junit.jupiter.api;\n" +
"@org.junit.platform.commons.annotation.Testable\n" +
"public @interface Test {}");
addEnvironmentClass("package org.junit.jupiter.api;\n" +
"public @interface AfterEach {}");
@@ -48,6 +52,7 @@ public class JUnit5MalformedRepeatedTest extends LightInspectionTestCase {
addEnvironmentClass("package org.junit.jupiter.api;\n" +
"public interface TestReporter {}");
addEnvironmentClass("package org.junit.jupiter.api;\n" +
"@org.junit.platform.commons.annotation.Testable\n" +
"public @interface ParameterizedTest {}");
}