CHAPTER 6
ENUMS AND ANNOTATIONS
184
Now let’s modify the test runner tool to process the new annotation. Doing so
consists of adding the following code to the
main
method:
if (m.isAnnotationPresent(ExceptionTest.class)) {
tests++;
try {
m.invoke(null);
System.out.printf("Test %s failed: no exception%n", m);
} catch (InvocationTargetException wrappedEx) {
Throwable exc = wrappedEx.getCause();
Do'stlaringiz bilan baham: