@SuppressWarnings("unchecked")
   private static <E> List<Class<E>> findClasses(File directory, String packageName) throws ClassNotFoundException {
      List<Class<E>> classes = new ArrayList<Class<E>>();
      if (!directory.exists()) {
         return classes;
      }
      File[] files = directory.listFiles();
      for (File file : files) {
         if (file.isDirectory()) {
            assert !file.getName().contains(".");
            classes.addAll(TestRig.<E>findClasses(file, packageName + "." + file.getName()));
         } else if (file.getName().endsWith(".class")) {
            classes.add((Class<E>)Class.forName(packageName + '.' + file.getName().substring(0, file.getName().length() - 6)));
         }
      }
      return classes;
   }