package seedu.address.testutil;

import junit.framework.AssertionFailedError;

/**
 * A utility class for test cases.
 */
public class TestUtil {

    public static void assertThrows(Class<? extends Throwable> expected, Runnable executable) {
        try {
            executable.run();
        } catch (Throwable actualException) {
            if (!actualException.getClass().isAssignableFrom(expected)) {
                String message = String.format("Expected thrown: %s, actual: %s", expected.getName(),
                        actualException.getClass().getName());
                throw new AssertionFailedError(message);
            } else {
                return;
            }
        }
        throw new AssertionFailedError(
                String.format("Expected %s to be thrown, but nothing was thrown.", expected.getName()));
    }

}

@@ -140,16 +140,105 @@
 Util %7B%0A%0A
+    public interface AssertThrowsCallback %7B%0A        void call() throws Exception;%0A    %7D%0A%0A
     publ
@@ -306,27 +306,37 @@
 ed, 
-Runnable executable
+AssertThrowsCallback callback
 ) %7B%0A
@@ -365,22 +365,21 @@
     
-executable.run
+callback.call
 ();%0A

allow callback to throw checked exceptions