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;
 }
Ejemplo n.º 2
0
  public static boolean isHeadlessEnv() {
    Application app = ApplicationManager.getApplication();
    if (app == null) return GraphicsEnvironment.isHeadless();

    return app.isUnitTestMode() || app.isHeadlessEnvironment();
  }