void (Test test) { String className = getClassName(test); String methodName = getMethodName(test); try { Object data = getData(); Method testEnded = data.getClass().getMethod("testDiscoveryEnded", String.class, String.class); testEnded.invoke(data, className, methodName); } catch (Throwable t) { t.printStackTrace(); } }