import java.lang.reflect.Method;
import java.util.Arrays;

public class RunnerManual {

    public static void main(String[] args) {
        int lulus = 0;
        int gagal = 0;

        Method[] semua = KalkulatorTest.class.getDeclaredMethods();
        Arrays.sort(semua, (m1, m2) -> m1.getName().compareTo(m2.getName()));

        for (Method method : semua) {
            if (!method.getName().startsWith("test")) {
                continue; // bukan method uji
            }
            Object uji = new KalkulatorTest();
            try {
                method.invoke(uji);
                lulus++;
                System.out.println("LULUS  " + method.getName());
            } catch (Exception e) {
                gagal++;
                Throwable sebab = e.getCause() != null ? e.getCause() : e;
                System.out.println("GAGAL  " + method.getName()
                    + " -> " + sebab.getMessage());
            }
        }
        System.out.println("ringkasan: " + lulus + " lulus, " + gagal + " gagal");
    }
}
