Commit eded65fe authored by Sergey Ignatov's avatar Sergey Ignatov
Browse files

test case loader: process annotations though the hierarchy

parent 9f0d25b4
Showing with 17 additions and 21 deletions
+17 -21
......@@ -18,6 +18,7 @@ import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
......@@ -246,7 +247,7 @@ public class TestCaseLoader {
}
private static boolean runFirst(Class testClass) {
return testClass.getAnnotation(RunFirst.class) != null;
return getAnnotationInHierarchy(testClass, RunFirst.class) != null;
}
private static boolean isPlatformLiteFixture(Class aClass) {
......@@ -320,4 +321,17 @@ public class TestCaseLoader {
System.out.println(message);
TeamCityLogger.info(message);
}
@Nullable
public static <T extends Annotation> T getAnnotationInHierarchy(@NotNull Class<?> clazz, @NotNull Class<T> annotationClass) {
Class<?> current = clazz;
while (current != null) {
T annotation = current.getAnnotation(annotationClass);
if (annotation != null) {
return annotation;
}
current = current.getSuperclass();
}
return null;
}
}
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.groovy.util;
import com.intellij.TestAll;
import com.intellij.TestCaseLoader;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.junit.runners.Suite;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.RunnerBuilder;
import java.lang.annotation.Annotation;
import java.util.List;
/**
......@@ -51,19 +46,6 @@ public class AllTestsSuite extends Suite {
}
private static boolean isSlow(Class aClass) {
return getAnnotationInHierarchy(aClass, Slow.class) != null;
}
@Nullable
private static <T extends Annotation> T getAnnotationInHierarchy(@NotNull Class<?> clazz, @NotNull Class<T> annotationClass) {
Class<?> current = clazz;
while (current != null) {
T annotation = current.getAnnotation(annotationClass);
if (annotation != null) {
return annotation;
}
current = current.getSuperclass();
}
return null;
return TestCaseLoader.getAnnotationInHierarchy(aClass, Slow.class) != null;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment