public static boolean canRunTest(@NotNull Class testCaseClass) {
   if (GraphicsEnvironment.isHeadless()) {
     for (Class<?> clazz = testCaseClass; clazz != null; clazz = clazz.getSuperclass()) {
       if (clazz.getAnnotation(SkipInHeadlessEnvironment.class) != null) {
         System.out.println(
             "Class '"
                 + testCaseClass.getName()
                 + "' is skipped because it requires working UI environment");
         return false;
       }
     }
   }
   return true;
 }
Пример #2
0
 protected boolean annotatedWith(@NotNull Class annotationClass) {
   Class<?> aClass = getClass();
   String methodName = "test" + getTestName(false);
   boolean methodChecked = false;
   while (aClass != null && aClass != Object.class) {
     if (aClass.getAnnotation(annotationClass) != null) return true;
     if (!methodChecked) {
       try {
         Method method = aClass.getDeclaredMethod(methodName);
         if (method.getAnnotation(annotationClass) != null) return true;
         methodChecked = true;
       } catch (NoSuchMethodException ignored) {
       }
     }
     aClass = aClass.getSuperclass();
   }
   return false;
 }
Пример #3
0
 private static String getTagNameFromAnnotation(Class<?> aClass) {
   Tag tag = aClass.getAnnotation(Tag.class);
   if (tag != null && !tag.value().isEmpty()) return tag.value();
   return null;
 }