void (@NotNull Throwable toThrow, Throwable expectedToBeLogged) { AtomicBoolean run = new AtomicBoolean(); InvocationEvent event = new InvocationEvent(this, () -> { run.set(true); ExceptionUtil.rethrow(toThrow); }); Runnable runnable = () -> { IdeEventQueue ideEventQueue = IdeEventQueue.getInstance(); ideEventQueue.executeInProductionModeEvenThoughWeAreInTests(() -> ideEventQueue.dispatchEvent(event)); }; Throwable error; if (expectedToBeLogged != null) { error = LoggedErrorProcessor.executeAndReturnLoggedError(runnable); } else { runnable.run(); error = null; } assertTrue(run.get()); assertSame(expectedToBeLogged, error); }