org.junit.internal.runners.MethodRoadie Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of junit-dep Show documentation
Show all versions of junit-dep Show documentation
JUnit is a regression testing framework written by Erich Gamma and Kent Beck.
It is used by the developer who implements unit tests in Java.
package org.junit.internal.runners;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.junit.internal.AssumptionViolatedException;
import org.junit.runner.Description;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.BlockJUnit4ClassRunner;
/**
* @deprecated Included for backwards compatibility with JUnit 4.4. Will be
* removed in the next release. Please use
* {@link BlockJUnit4ClassRunner} in place of {@link JUnit4ClassRunner}.
*/
@Deprecated
public class MethodRoadie {
private final Object fTest;
private final RunNotifier fNotifier;
private final Description fDescription;
private TestMethod fTestMethod;
public MethodRoadie(Object test, TestMethod method, RunNotifier notifier, Description description) {
fTest= test;
fNotifier= notifier;
fDescription= description;
fTestMethod= method;
}
public void run() {
if (fTestMethod.isIgnored()) {
fNotifier.fireTestIgnored(fDescription);
return;
}
fNotifier.fireTestStarted(fDescription);
try {
long timeout= fTestMethod.getTimeout();
if (timeout > 0)
runWithTimeout(timeout);
else
runTest();
} finally {
fNotifier.fireTestFinished(fDescription);
}
}
private void runWithTimeout(final long timeout) {
runBeforesThenTestThenAfters(new Runnable() {
public void run() {
ExecutorService service= Executors.newSingleThreadExecutor();
Callable