void () { DefaultLogger.disableStderrDumping(getTestRootDisposable()); String msg = "expected message"; try { assertThrows(AssertionError.class, () -> ProgressManager.getInstance().run(new Task.Modal(getProject(), "Title", true) { @Override public void run(@NotNull ProgressIndicator indicator) { ApplicationManager.getApplication().invokeLater(() -> { throw new AssertionError(msg); }); // ensure previous runnable is executed during progress, not after it ApplicationManager.getApplication().invokeAndWait(EmptyRunnable.getInstance()); } })); assertSame(ModalityState.nonModal(), ModalityState.current()); } finally { LaterInvocator.leaveAllModals(); } }