Skip to content

Commit

Permalink
Merge pull request #716 from brettchabot/master
Browse files Browse the repository at this point in the history
Fix annotation collection from super classes of JUnit3 tests.
  • Loading branch information
David Saff committed Aug 20, 2013
2 parents db32e53 + 8105369 commit 53e940c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private static Description makeDescription(Test test) {
*/
private static Annotation[] getAnnotations(TestCase test) {
try {
Method m = test.getClass().getDeclaredMethod(test.getName());
Method m = test.getClass().getMethod(test.getName());
return m.getDeclaredAnnotations();
} catch (SecurityException e) {
} catch (NoSuchMethodException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,22 @@ public void testNotAnnotated() {
}
}

public static class DerivedAnnotatedMethod extends JUnit3ClassWithAnnotatedMethod {
}

@Test
public void getDescriptionWithAnnotation() {
JUnit38ClassRunner runner = new JUnit38ClassRunner(JUnit3ClassWithAnnotatedMethod.class);
assertAnnotationFiltering(runner);
}

@Test
public void getDescriptionWithAnnotationInSuper() {
JUnit38ClassRunner runner = new JUnit38ClassRunner(DerivedAnnotatedMethod.class);
assertAnnotationFiltering(runner);
}

private void assertAnnotationFiltering(JUnit38ClassRunner runner) {
Description d = runner.getDescription();
assertEquals(2, d.testCount());
for (Description methodDesc : d.getChildren()) {
Expand Down

0 comments on commit 53e940c

Please sign in to comment.