### Question:
RecordCommand implements Command { @Override public void run() { Optional<Process> virtualScreenProcessOptional = Optional.empty(); try { if (screen != 0) { virtualScreenProcessOptional = Optional.of(virtualScreenProcessCreator.createXvfbProcess(screen)); } RecordBrowser recordBrowser = recordBrowserBaseIOProvider.get(); recordBrowser.record(); logger.info("Ready for recording, waiting for user input. Will terminate when ENTER is pressed"); promptUtils.promptForRecording(); TestScenarioSteps testScenarioSteps = recordBrowser.getTestCaseSteps(); stepsDumperProvider.get().dump(testScenarioSteps, outputFile); recordBrowser.cleanUp(); } catch (IOException | URISyntaxException e) { logger.error("Error while recording", e); } finally { virtualScreenProcessOptional.ifPresent(Process::destroy); } } @Inject  RecordCommand(@Named(OUTPUT_FILE) String outputFile,
                         @Named(SCREEN_NUMBER) int screen,
                         PromptUtils promptUtils,
                         IOURIProvider<RecordBrowser> recordBrowserBaseIOProvider,
                         VirtualScreenProcessCreator virtualScreenProcessCreator,
                         IOProvider<StepsDumper> stepsDumperProvider); @Override void run();  }### Answer:
@Test public void ifIOExceptionExceptionIsThrownDoesNotDumpActions() throws IOException { RecordCommand recordCommand = new RecordCommand( outputFile, screen, promptUtils, () -> { throw new IOException("Terrible exception happened!"); }, virtualScreenProcessCreator, () -> stepsDumper ); recordCommand.run(); verify(stepsDumper, never()).dump(testScenarioSteps, outputFile); }
@Test public void ifURISyntaxExceptionIsThrownDoesNotDumpActions() throws IOException { RecordCommand recordCommand = new RecordCommand( outputFile, screen, promptUtils, () -> { throw new URISyntaxException("", ""); }, virtualScreenProcessCreator, () -> stepsDumper ); recordCommand.run(); verify(stepsDumper, never()).dump(testScenarioSteps, outputFile); }