Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ addons:
packages:
- openjdk-6-jdk
jdk:
- oraclejdk9
- oraclejdk8
- openjdk7
- openjdk6
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -558,5 +558,15 @@
</plugins>
</reporting>
</profile>
<profile>
<id>java9</id>
<activation>
<jdk>[1.9,)</jdk>
</activation>
<properties>
<!-- JDK 9 minimal source and target versions are 1.6 -->
<jdkVersion>1.6</jdkVersion>
</properties>
</profile>
</profiles>
</project>
1 change: 1 addition & 0 deletions src/main/java/org/junit/internal/Throwables.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ private static boolean isTestFrameworkMethod(String methodName) {
private static final String[] REFLECTION_METHOD_NAME_PREFIXES = {
"sun.reflect.",
"java.lang.reflect.",
"jdk.internal.reflect.",
"org.junit.rules.RunRules.<init>(",
"org.junit.rules.RunRules.applyAll(", // calls TestRules
"org.junit.runners.RuleContainer.apply(", // calls MethodRules & TestRules
Expand Down
48 changes: 33 additions & 15 deletions src/test/java/org/junit/runners/model/TestClassTest.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package org.junit.runners.model;

import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.List;

import org.junit.Ignore;
Expand Down Expand Up @@ -132,26 +131,45 @@ public String methodA() {
@Test
public int methodB() {
return 0;
}
}

public int methodWithoutAnnotation() {
return 0;
}
}

@Test
public void providesAnnotatedMethodsSortedByName() {
TestClass tc = new TestClass(MethodsAnnotated.class);
List<FrameworkMethod> annotatedMethods = tc.getAnnotatedMethods();
assertThat("Wrong number of annotated methods.",
annotatedMethods.size(), is(3));
assertThat("First annotated method is wrong.", annotatedMethods
.iterator().next().getName(), is("methodA"));
TestClass tc = new TestClass(MethodsAnnotated.class);
List<FrameworkMethod> annotatedMethods = tc.getAnnotatedMethods();
List<String> methodNames = extractNames(annotatedMethods);
assertThat(methodNames.indexOf("methodA"),
lessThan(methodNames.indexOf("methodB")));
}

@Test
public void getAnnotatedMethodsDoesNotReturnMethodWithoutAnnotation() {
TestClass tc = new TestClass(MethodsAnnotated.class);
List<FrameworkMethod> annotatedMethods = tc.getAnnotatedMethods();
List<String> methodNames = extractNames(annotatedMethods);
assertThat(methodNames, not(hasItem("methodWithoutAnnotation")));
}

private List<String> extractNames(List<FrameworkMethod> methods) {
List<String> names = new ArrayList<String>();
for (FrameworkMethod method: methods) {
names.add(method.getName());
}
return names;
}

@Test
public void annotatedMethodValues() {
TestClass tc = new TestClass(MethodsAnnotated.class);
List<String> values = tc.getAnnotatedMethodValues(
new MethodsAnnotated(), Ignore.class, String.class);
assertThat(values, hasItem("jupiter"));
assertThat(values.size(), is(1));
TestClass tc = new TestClass(MethodsAnnotated.class);
List<String> values = tc.getAnnotatedMethodValues(
new MethodsAnnotated(), Ignore.class, String.class);
assertThat(values, hasItem("jupiter"));
assertThat(values.size(), is(1));
}

@Test
Expand Down