1 package org.robolectric; 2 3 import java.lang.reflect.Method; 4 5 public class DefaultTestLifecycle implements TestLifecycle { 6 7 /** 8 * Called before each test method is run. 9 * 10 * @param method the test method about to be run 11 */ beforeTest(final Method method)12 @Override public void beforeTest(final Method method) { 13 if (RuntimeEnvironment.application instanceof TestLifecycleApplication) { 14 ((TestLifecycleApplication) RuntimeEnvironment.application).beforeTest(method); 15 } 16 } 17 prepareTest(final Object test)18 @Override public void prepareTest(final Object test) { 19 if (RuntimeEnvironment.application instanceof TestLifecycleApplication) { 20 ((TestLifecycleApplication) RuntimeEnvironment.application).prepareTest(test); 21 } 22 } 23 24 /** 25 * Called after each test method is run. 26 * 27 * @param method the test method that just ran. 28 */ afterTest(final Method method)29 @Override public void afterTest(final Method method) { 30 if (RuntimeEnvironment.application instanceof TestLifecycleApplication) { 31 ((TestLifecycleApplication) RuntimeEnvironment.application).afterTest(method); 32 } 33 } 34 } 35