1 package org.junit.internal.runners.statements;
2 
3 import java.util.List;
4 
5 import org.junit.runners.model.FrameworkMethod;
6 import org.junit.runners.model.Statement;
7 
8 public class RunBefores extends Statement {
9     private final Statement next;
10 
11     private final Object target;
12 
13     private final List<FrameworkMethod> befores;
14 
RunBefores(Statement next, List<FrameworkMethod> befores, Object target)15     public RunBefores(Statement next, List<FrameworkMethod> befores, Object target) {
16         this.next = next;
17         this.befores = befores;
18         this.target = target;
19     }
20 
21     @Override
evaluate()22     public void evaluate() throws Throwable {
23         for (FrameworkMethod before : befores) {
24             invokeMethod(before);
25         }
26         next.evaluate();
27     }
28 
29     /**
30      * @since 4.13
31      */
invokeMethod(FrameworkMethod method)32     protected void invokeMethod(FrameworkMethod method) throws Throwable {
33         method.invokeExplosively(target);
34     }
35 }