package com.xtremelabs.droidsugar;

import java.lang.reflect.Method;

import org.junit.internal.runners.JUnit4ClassRunner;
import org.junit.runner.notification.RunNotifier;

public class AbstractAndroidTestRunner extends JUnit4ClassRunner {
    private ClassHandler classHandler;

    public AbstractAndroidTestRunner(Class<?> testClass, Loader loader) throws org.junit.internal.runners.InitializationError {
        super(loader.bootstrap(testClass));
    }

    public AbstractAndroidTestRunner(Class<?> testClass, Loader loader, ClassHandler classHandler) throws org.junit.internal.runners.InitializationError {
        this(testClass, loader);
        this.classHandler = classHandler;

        loader.delegateLoadingOf(getClass().getName());
    }

    @Override
    protected void invokeTestMethod(Method method, RunNotifier notifier) {
        if (classHandler != null) classHandler.beforeTest();

        super.invokeTestMethod(method, notifier);

        if (classHandler != null) classHandler.afterTest();
    }
}

@@ -894,24 +894,52 @@
 oreTest();%0A%0A
+        beforeTest(method);%0A
         supe
@@ -975,16 +975,43 @@
 tifier);
+%0A        afterTest(method);
 %0A%0A      
@@ -1069,11 +1069,118 @@
 );%0A    %7D
+%0A%0A    protected void beforeTest(Method method) %7B%0A    %7D%0A%0A    protected void afterTest(Method method) %7B%0A    %7D
 %0A%7D%0A

Add before/after test hook to AbstractAndroidTestRunner.