void (final Runnable action, boolean confirmationExpected) { final Ref<Boolean> dialogShown = Ref.create(false); final TestDialog oldDialog = TestDialogManager.setTestDialog(new TestDialog() { @Override public int show(@NotNull String message) { dialogShown.set(true); return 0; } }); try { action.run(); } finally { TestDialogManager.setTestDialog(oldDialog); } if (confirmationExpected) { assertTrue("Dialog wasn't shown", dialogShown.get()); } else { assertFalse("Dialog was shown", dialogShown.get()); } }