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