aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/junit/internal/runners/ClassRoadie.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/junit/internal/runners/ClassRoadie.java')
-rw-r--r--src/main/java/org/junit/internal/runners/ClassRoadie.java118
1 files changed, 60 insertions, 58 deletions
diff --git a/src/main/java/org/junit/internal/runners/ClassRoadie.java b/src/main/java/org/junit/internal/runners/ClassRoadie.java
index 1f77d37..df1b453 100644
--- a/src/main/java/org/junit/internal/runners/ClassRoadie.java
+++ b/src/main/java/org/junit/internal/runners/ClassRoadie.java
@@ -4,6 +4,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
+import org.junit.internal.AssumptionViolatedException;
import org.junit.runner.Description;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunNotifier;
@@ -11,69 +12,70 @@ 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 ClassRoadie {
- private RunNotifier fNotifier;
- private TestClass fTestClass;
- private Description fDescription;
- private final Runnable fRunnable;
-
- public ClassRoadie(RunNotifier notifier, TestClass testClass,
- Description description, Runnable runnable) {
- fNotifier= notifier;
- fTestClass= testClass;
- fDescription= description;
- fRunnable= runnable;
- }
+public class ClassRoadie {
+ private RunNotifier notifier;
+ private TestClass testClass;
+ private Description description;
+ private final Runnable runnable;
- protected void runUnprotected() {
- fRunnable.run();
- };
+ public ClassRoadie(RunNotifier notifier, TestClass testClass,
+ Description description, Runnable runnable) {
+ this.notifier = notifier;
+ this.testClass = testClass;
+ this.description = description;
+ this.runnable = runnable;
+ }
- protected void addFailure(Throwable targetException) {
- fNotifier.fireTestFailure(new Failure(fDescription, targetException));
- }
+ protected void runUnprotected() {
+ runnable.run();
+ }
- public void runProtected() {
- try {
- runBefores();
- runUnprotected();
- } catch (FailedBefore e) {
- } finally {
- runAfters();
- }
- }
+ protected void addFailure(Throwable targetException) {
+ notifier.fireTestFailure(new Failure(description, targetException));
+ }
- private void runBefores() throws FailedBefore {
- try {
- try {
- List<Method> befores= fTestClass.getBefores();
- for (Method before : befores)
- before.invoke(null);
- } catch (InvocationTargetException e) {
- throw e.getTargetException();
- }
- } catch (org.junit.internal.AssumptionViolatedException e) {
- throw new FailedBefore();
- } catch (Throwable e) {
- addFailure(e);
- throw new FailedBefore();
- }
- }
+ public void runProtected() {
+ try {
+ runBefores();
+ runUnprotected();
+ } catch (FailedBefore e) {
+ } finally {
+ runAfters();
+ }
+ }
- private void runAfters() {
- List<Method> afters= fTestClass.getAfters();
- for (Method after : afters)
- try {
- after.invoke(null);
- } catch (InvocationTargetException e) {
- addFailure(e.getTargetException());
- } catch (Throwable e) {
- addFailure(e); // Untested, but seems impossible
- }
- }
-} \ No newline at end of file
+ private void runBefores() throws FailedBefore {
+ try {
+ try {
+ List<Method> befores = testClass.getBefores();
+ for (Method before : befores) {
+ before.invoke(null);
+ }
+ } catch (InvocationTargetException e) {
+ throw e.getTargetException();
+ }
+ } catch (AssumptionViolatedException e) {
+ throw new FailedBefore();
+ } catch (Throwable e) {
+ addFailure(e);
+ throw new FailedBefore();
+ }
+ }
+
+ private void runAfters() {
+ List<Method> afters = testClass.getAfters();
+ for (Method after : afters) {
+ try {
+ after.invoke(null);
+ } catch (InvocationTargetException e) {
+ addFailure(e.getTargetException());
+ } catch (Throwable e) {
+ addFailure(e); // Untested, but seems impossible
+ }
+ }
+ }
+}