fix bug where @Test A::test(), B extends A, B::test() without @Test would be run twice

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1044315 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2010-12-10 12:01:05 +00:00
parent 14f4e0475d
commit 790a492be3
1 changed files with 4 additions and 4 deletions

View File

@ -986,7 +986,7 @@ public abstract class LuceneTestCase extends Assert {
if (testMethods != null)
return testMethods;
testClassesRun.add(getTestClass().getJavaClass().getSimpleName());
testMethods = getTestClass().getAnnotatedMethods(Test.class);
testMethods = new ArrayList<FrameworkMethod>();
for (Method m : getTestClass().getJavaClass().getMethods()) {
// check if the current test's class has methods annotated with @Ignore
final Ignore ignored = m.getAnnotation(Ignore.class);
@ -995,11 +995,11 @@ public abstract class LuceneTestCase extends Assert {
}
// add methods starting with "test"
final int mod = m.getModifiers();
if (m.getName().startsWith("test") &&
m.getAnnotation(Test.class) == null &&
if (m.getAnnotation(Test.class) != null ||
(m.getName().startsWith("test") &&
!Modifier.isAbstract(mod) &&
m.getParameterTypes().length == 0 &&
m.getReturnType() == Void.TYPE)
m.getReturnType() == Void.TYPE))
{
if (Modifier.isStatic(mod))
throw new RuntimeException("Test methods must not be static.");