void (@NotNull Process testProcess, @NotNull Consumer<? super ProcessHandler> actionToTest) { KillableColoredProcessHandler handler = new KillableColoredProcessHandler(testProcess, "testProcess"); handler.setShouldDestroyProcessRecursively(false); handler.setShouldKillProcessSoftly(false); handler.startNotify(); handler.notifyTextAvailable("Running stuff...\n", ProcessOutputTypes.STDOUT); try { actionToTest.consume(handler); } finally { handler.destroyProcess(); handler.waitFor(); } }