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

public class RunnerJupiterMini {

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

        Method[] semua = PembersihTeksTest.class.getDeclaredMethods();
        Arrays.sort(semua, (a, b) -> a.getName().compareTo(b.getName()));

        for (Method method : semua) {
            if (!method.isAnnotationPresent(Uji.class)) {
                continue; // bukan method uji
            }
            String label = method.getAnnotation(Uji.class).nama();
            if (label.isEmpty()) {
                label = method.getName();
            }
            try {
                method.invoke(new PembersihTeksTest());
                lulus++;
                System.out.println("LULUS  [" + label + "]");
            } catch (Exception e) {
                gagal++;
                Throwable sebab = e.getCause() != null ? e.getCause() : e;
                System.out.println("GAGAL  [" + label + "] -> " + sebab.getMessage());
            }
        }
        System.out.println("ringkasan: " + lulus + " lulus, " + gagal + " gagal");
    }
}
