m.getParameterTypes().length == 0 &&
m.getReturnType() == Void.TYPE))
{
if (Modifier.isStatic(mod))
throw new RuntimeException("Test methods must not be static.");
testMethods.add(new FrameworkMethod(m));
}
}
if (testMethods.isEmpty()) {
throw new RuntimeException("No runnable methods!");
}
if (TEST_NIGHTLY == false) {
if (getTestClass().getJavaClass().isAnnotationPresent(Nightly.class)) {
/* the test class is annotated with nightly, remove all methods */
String className = getTestClass().getJavaClass().getSimpleName();
System.err.println("NOTE: Ignoring nightly-only test class '" + className + "'");
testMethods.clear();
} else {
/* remove all nightly-only methods */
for (int i = 0; i < testMethods.size(); i++) {
final FrameworkMethod m = testMethods.get(i);
if (m.getAnnotation(Nightly.class) != null) {
System.err.println("NOTE: Ignoring nightly-only test method '" + m.getName() + "'");
testMethods.remove(i--);
}
}
}
/* dodge a possible "no-runnable methods" exception by adding a fake ignored test */
if (testMethods.isEmpty()) {
try {
testMethods.add(new FrameworkMethod(LuceneTestCase.class.getMethod("alwaysIgnoredTestMethod")));
} catch (Exception e) { throw new RuntimeException(e); }
}
}
// sort the test methods first before shuffling them, so that the shuffle is consistent
// across different implementations that might order the methods different originally.