How to check if a Java class contains JUnit4 tests?
问题 I have a Java class. How can I check if the class contains methods that are JUnit4 tests? Do I have to do an iteration on all methods using reflection, or does JUnit4 supply such a check? Edit: since comments cannot contain code, I placed my code based on the answer here: private static boolean containsUnitTests(Class<?> clazz) { List<FrameworkMethod> methods= new TestClass(clazz).getAnnotatedMethods(Test.class); for (FrameworkMethod eachTestMethod : methods) { List<Throwable> errors = new