Index: src/test/org/apache/lucene/util/LuceneTestCaseJ4.java =================================================================== --- src/test/org/apache/lucene/util/LuceneTestCaseJ4.java (revision 916685) +++ src/test/org/apache/lucene/util/LuceneTestCaseJ4.java (working copy) @@ -25,6 +25,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Rule; +import org.junit.Test; import org.junit.rules.TestWatchman; import org.junit.runners.model.FrameworkMethod; @@ -34,7 +35,10 @@ import java.util.Random; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.WeakHashMap; import java.util.Collections; +import java.lang.reflect.Method; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -96,6 +100,11 @@ } private List uncaughtExceptions = Collections.synchronizedList(new ArrayList()); + // checks if class correctly annotated + private static final Object PLACEHOLDER = new Object(); + private static final Map,Object> checkedClasses = + Collections.synchronizedMap(new WeakHashMap,Object>()); + // This is how we get control when errors occur. // Think of this as start/end/success/failed // events. @@ -110,7 +119,18 @@ @Override public void starting(FrameworkMethod method) { + // set current method name for logging LuceneTestCaseJ4.this.name = method.getName(); + // check if the current test's class annotated all test* methods with @Test + final Class clazz = LuceneTestCaseJ4.this.getClass(); + if (!checkedClasses.containsKey(clazz)) { + checkedClasses.put(clazz, PLACEHOLDER); + for (Method m : clazz.getMethods()) { + if (m.getName().startsWith("test") && m.getAnnotation(Test.class) == null) { + fail("In class '" + clazz.getName() + "' the method '" + m.getName() + "' is not annotated with @Test."); + } + } + } super.starting(method); }