CustomExceptionHandler implements Thread.UncaughtExceptionHandler { @Override public void uncaughtException(Thread thread, Throwable ex) { storeException(thread, ex); defaultHandler.uncaughtException(thread, ex); } CustomExceptionHandler(Context context, List<CrashReportingService> crashReportingServices, boolean wifiOnly); @Override void uncaughtException(Thread thread, Throwable ex);  }
@Test public void testUncaughtException() { Thread.UncaughtExceptionHandler mockDefaultExceptionHandler = mock(Thread.UncaughtExceptionHandler.class); CustomExceptionHandler customExceptionHandler = mock(CustomExceptionHandler.class); doCallRealMethod().when(customExceptionHandler).uncaughtException(any(Thread.class), any(Throwable.class)); customExceptionHandler.defaultHandler = mockDefaultExceptionHandler; Thread thread = new Thread(); Throwable throwable = new Throwable(); customExceptionHandler.uncaughtException(thread, throwable); verify(customExceptionHandler).storeException(eq(thread), eq(throwable)); verify(mockDefaultExceptionHandler).uncaughtException(eq(thread), eq(throwable)); }