Created
May 10, 2016 16:13
-
-
Save swegner/d6425e703d10d82600d0e98319257c82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testPrefix() throws IOException { | |
ClassPath cp = ClassPath.from(ClassLoader.getSystemClassLoader()); | |
Set<ClassPath.ClassInfo> classes = cp.getAllClasses(); | |
int prefixed = 0; | |
int unPrefixed = 0; | |
for (ClassPath.ClassInfo classInfo : classes) { | |
Class<?> clazz; | |
if (!classInfo.getPackageName().startsWith("org.apache.beam")) { | |
continue; | |
} | |
try { | |
clazz = classInfo.load(); | |
} catch (NoClassDefFoundError e) { | |
System.err.println(String.format("Failed to load class %s: %s", classInfo.getName(), e)); | |
continue; | |
} | |
for (Method method : clazz.getDeclaredMethods()) { | |
if (method.isAnnotationPresent(Test.class)) { | |
if (method.getName().startsWith("test")) { | |
prefixed++; | |
} else | |
unPrefixed++; | |
} | |
} | |
} | |
System.out.println(String.format("Prefixed: %d, Unprefixed: %d", prefixed, unPrefixed)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment