void () { var t = new RuntimeException(); class ThrowingIndicator extends EmptyProgressIndicator implements BlockingProgressIndicator { @Override public void startBlocking(@NotNull Runnable init, @NotNull CompletableFuture<?> stopCondition) { // "enter" modality init.run(); // wait for task future to complete try { stopCondition.get(1000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { throw new RuntimeException(e); } throw t; } } ProgressResult<?> result = computeAssertingExceptionConditionally( !myOnEdt || myReleaseIWLockOnRun, () -> { return new ProgressRunner<>(EmptyRunnable.getInstance()) .onThread(ProgressRunner.ThreadToUse.POOLED) .withProgress(new ThrowingIndicator()) .modal() .submitAndGet(); }); if (result == null) { return; } assertFalse(result.isCanceled()); assertSame(t, result.getThrowable()); }