### Question:
ErrorLog { void log(Throwable throwable) { errors.append(toLogMessage(throwable)); for (Throwable cause = throwable.getCause(); cause != null; cause = cause.getCause()) errors.append(System.lineSeparator()).append(" ").append(toLogMessage(cause)); }    }### Answer:
@Test public void afterExceptionReported_isAddedToLog() { errorLog.log(new IOException("Unable to read value")); assertThat(errorLog, containsErrors("IOException: Unable to read value")); }
@Test public void afterExceptionWithNoMessageReported_logSimpleNameOnly() { errorLog.log(new IOException()); assertThat(errorLog, containsErrors("IOException")); }
@Test public void afterExceptionWithNestedThrowableReported_addToLog() { errorLog.log(new IOException("Unable to read value", new RuntimeException("has impossible format"))); assertThat(errorLog, containsErrors("IOException: Unable to read value", " RuntimeException: has impossible format")); }