### Question:
LogServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { String errors = LiveConfiguration.getErrors(); if (errors == null || errors.trim().length() == 0) resp.getOutputStream().println("No errors reported."); else resp.getOutputStream().println("<blockquote>" + errors + "</blockquote>"); resp.getOutputStream().close(); }    }### Answer:
@Test public void whenNoErrorsReported_saySo() throws ServletException, IOException { servlet.doGet(request, response); assertThat(response.getHtml(), containsString("No errors reported.")); }
@Test public void whenErrorsReported_listThem() throws NoSuchFieldException, ServletException, IOException { ErrorLog errorLog = new ErrorLog(); mementos.add(StaticStubSupport.install(LiveConfiguration.class, "errorLog", errorLog)); errorLog.log(new WebClientException("Unable to reach server")); servlet.doGet(request, response); assertThat(response.getHtml(), containsString("WebClientException: Unable to reach server")); }