aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/junit/internal/runners/TestMethod.java
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2016-12-14 11:49:43 +0000
committerPaul Duffin <paulduffin@google.com>2016-12-20 15:52:52 +0000
commitaeb93fc33cae3aadbb9b46083350ad2dc9aea645 (patch)
treeb316db7dee11d1aeee3510562e036fd41705b8b5 /src/main/java/org/junit/internal/runners/TestMethod.java
parent26401927b83770db45f00706ccc589955644c6c2 (diff)
downloadjunit-aeb93fc33cae3aadbb9b46083350ad2dc9aea645.tar.gz
Upgrade to JUnit 4.12
The license has changed from Common Public License v1.0 to Eclipse Public License v1.0. This will not compile as it is because it is intended to be built against Hamcrest 1.3 or later but it is being built against Hamcrest 1.1. A follow on patch will fix the compilation errors so that it builds against Hamcrest 1.1. That allows Hamcrest to be upgraded separately. The patch can be reverted once Hamcrest has been upgraded. There are also some Android specific issues that will also be fixed in follow on patches. Bug: 33613916 Test: make checkbuild Change-Id: Ic2c983a030399e3ace1a14927cb143fbd8307b4f
Diffstat (limited to 'src/main/java/org/junit/internal/runners/TestMethod.java')
-rw-r--r--src/main/java/org/junit/internal/runners/TestMethod.java80
1 files changed, 41 insertions, 39 deletions
diff --git a/src/main/java/org/junit/internal/runners/TestMethod.java b/src/main/java/org/junit/internal/runners/TestMethod.java
index a06213c..821e193 100644
--- a/src/main/java/org/junit/internal/runners/TestMethod.java
+++ b/src/main/java/org/junit/internal/runners/TestMethod.java
@@ -13,57 +13,59 @@ import org.junit.runners.BlockJUnit4ClassRunner;
/**
* @deprecated Included for backwards compatibility with JUnit 4.4. Will be
- * removed in the next release. Please use
+ * removed in the next major release. Please use
* {@link BlockJUnit4ClassRunner} in place of {@link JUnit4ClassRunner}.
*/
@Deprecated
public class TestMethod {
- private final Method fMethod;
- private TestClass fTestClass;
+ private final Method method;
+ private TestClass testClass;
- public TestMethod(Method method, TestClass testClass) {
- fMethod= method;
- fTestClass= testClass;
- }
+ public TestMethod(Method method, TestClass testClass) {
+ this.method = method;
+ this.testClass = testClass;
+ }
- public boolean isIgnored() {
- return fMethod.getAnnotation(Ignore.class) != null;
- }
+ public boolean isIgnored() {
+ return method.getAnnotation(Ignore.class) != null;
+ }
- public long getTimeout() {
- Test annotation= fMethod.getAnnotation(Test.class);
- if (annotation == null)
- return 0;
- long timeout= annotation.timeout();
- return timeout;
- }
+ public long getTimeout() {
+ Test annotation = method.getAnnotation(Test.class);
+ if (annotation == null) {
+ return 0;
+ }
+ long timeout = annotation.timeout();
+ return timeout;
+ }
- protected Class<? extends Throwable> getExpectedException() {
- Test annotation= fMethod.getAnnotation(Test.class);
- if (annotation == null || annotation.expected() == None.class)
- return null;
- else
- return annotation.expected();
- }
+ protected Class<? extends Throwable> getExpectedException() {
+ Test annotation = method.getAnnotation(Test.class);
+ if (annotation == null || annotation.expected() == None.class) {
+ return null;
+ } else {
+ return annotation.expected();
+ }
+ }
- boolean isUnexpected(Throwable exception) {
- return ! getExpectedException().isAssignableFrom(exception.getClass());
- }
+ boolean isUnexpected(Throwable exception) {
+ return !getExpectedException().isAssignableFrom(exception.getClass());
+ }
- boolean expectsException() {
- return getExpectedException() != null;
- }
+ boolean expectsException() {
+ return getExpectedException() != null;
+ }
- List<Method> getBefores() {
- return fTestClass.getAnnotatedMethods(Before.class);
- }
+ List<Method> getBefores() {
+ return testClass.getAnnotatedMethods(Before.class);
+ }
- List<Method> getAfters() {
- return fTestClass.getAnnotatedMethods(After.class);
- }
+ List<Method> getAfters() {
+ return testClass.getAnnotatedMethods(After.class);
+ }
- public void invoke(Object test) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
- fMethod.invoke(test);
- }
+ public void invoke(Object test) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+ method.invoke(test);
+ }
}