Here you can find the source of assertException(Runnable task, Class> clazz)
public static void assertException(Runnable task, Class<?> clazz)
//package com.java2s; //License from project: Open Source License public class Main { public static void assertException(Runnable task, Class<?> clazz) { try {/*from w ww .j av a 2 s .c om*/ task.run(); throw new AssertionError(String.format("expected exception of type %s", clazz.getSimpleName())); } catch (Exception ex) { if (!ex.getClass().isAssignableFrom(clazz)) { new AssertionError(String.format("expected exception of type %s but found exception of type %s", clazz.getCanonicalName(), ex.getClass().getCanonicalName())); } } } }