1 /** 2 * 3 */ 4 package org.junit.internal.runners.model; 5 6 import org.junit.internal.AssumptionViolatedException; 7 import org.junit.runner.Description; 8 import org.junit.runner.notification.Failure; 9 import org.junit.runner.notification.RunNotifier; 10 import org.junit.runners.model.MultipleFailureException; 11 12 public class EachTestNotifier { 13 private final RunNotifier fNotifier; 14 15 private final Description fDescription; 16 17 public EachTestNotifier(RunNotifier notifier, Description description) { 18 fNotifier= notifier; 19 fDescription= description; 20 } 21 22 public void addFailure(Throwable targetException) { 23 if (targetException instanceof MultipleFailureException) { 24 addMultipleFailureException((MultipleFailureException) targetException); 25 } else { 26 fNotifier 27 .fireTestFailure(new Failure(fDescription, targetException)); 28 } 29 } 30 31 private void addMultipleFailureException(MultipleFailureException mfe) { 32 for (Throwable each : mfe.getFailures()) 33 addFailure(each); 34 } 35 36 public void addFailedAssumption(AssumptionViolatedException e) { 37 fNotifier.fireTestAssumptionFailed(new Failure(fDescription, e)); 38 } 39 40 public void fireTestFinished() { 41 fNotifier.fireTestFinished(fDescription); 42 } 43 44 public void fireTestStarted() { 45 fNotifier.fireTestStarted(fDescription); 46 } 47 48 public void fireTestIgnored() { 49 fNotifier.fireTestIgnored(fDescription); 50 } 51 }