### Question:
InternalErrorReportingExecutor extends InternalErrorReporter implements Executor { @Override public void execute(Runnable command) { backingExecutor.execute(new InternalErrorReporter(command)); } InternalErrorReportingExecutor(Executor backingExecutor, SuiteListener listener, PrintStream out); @Override void execute(Runnable command);  }### Answer:
@Test public void reports_internal_errors() { executor.execute(() -> { throw new RuntimeException("the-exception-message"); }); backingExecutor.processEventsUntilIdle(); String expected = String.format("Uncaught exception in thread %s", Thread.currentThread().getName()); verify(suiteListener).onInternalError(eq(expected), notNull(StackTrace.class)); }
@Test public void prints_internal_errors_to_standard_output() { executor.execute(() -> { throw new RuntimeException("the-exception-message"); }); backingExecutor.processEventsUntilIdle(); String output = standardOutput.toString(); assertThat(output, containsString("Uncaught exception in thread")); assertThat(output, containsString("java.lang.RuntimeException: the-exception-message")); }
@Test public void the_toString_of_the_original_commands_should_not_be_hidden() { SpyExecutor backingExecutor = new SpyExecutor(); InternalErrorReportingExecutor executor = new InternalErrorReportingExecutor(backingExecutor, suiteListener, new PrintStream(new NullOutputStream())); Runnable originalCommand = () -> { }; executor.execute(originalCommand); assertThat(backingExecutor.lastCommand.toString(), containsString(originalCommand.toString())); }