title: JUnit integration tests should report HTTP request/response details
body: <p>I'm writing some Integration Tests (ITs) that are being run using Maven Failsafe plugin.</p>
  
  <p>In short, these ITs perform an HTTP call and analyze the JSON response to ensure certain elements are present.</p>
  
  <p>When a test fails, I would like to be able to see the details of the HTTP request and response (headers, body, etc.), not just the assertion failure message.</p>
  
  <p>If my test looks something like this:</p>
  
  <pre><code>public class FooBarTest {
  
      MyHttpClient httpClient;
  
      @Before
      public void setupHttpClient(){
         this.httpClient = ...
      }
  
      @Test
      public void testFooBarBaz(){
         Response response = this.httpClient.get("http://some/url");
         Assert.assertEquals(200, response.getStatus());
         String json = response.getBody();
         Assert.assertEquals("baz", evalJsonPath(json, "foo.bar.id"));
      }
  }
  </code></pre>
  
  <p>When the test is run from command line (through Maven), I want to be able to see the assertion error and additionally the request and response details. I assume this requires printing to System.out/err but it's better done through some Logging system.</p>
  
  <p>Additionally, I want the same information to be available in the test TXT report file that surefire/failsafe produces:</p>
  
  <pre><code>-------------------------------------------------------------------------------
  Test set: com.sample.FooBarTest
  -------------------------------------------------------------------------------
  
  REQUEST: {...}
  RESPONSE: {...}
  
  Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 3.273 sec &lt;&lt;&lt; FAILURE! - in com.sample.FooBarTest
  testFooBarBaz(com.sample.FooBarTest)  Time elapsed: 3.27 sec  &lt;&lt;&lt; ERROR!
  junit.framework.AssertionFailedError: expected:&lt;200&gt; but was:&lt;404&gt;
       at junit.framework.Assert.fail(Assert.java:47)
       at junit.framework.Assert.failNotEquals(Assert.java:283)
       at junit.framework.Assert.assertEquals(Assert.java:64)
       at junit.framework.Assert.assertEquals(Assert.java:195)
       at junit.framework.Assert.assertEquals(Assert.java:201)
       at com.sample.FooBarTest.testFooBarBaz(FooBarTest.java:XX)
  </code></pre>
  
  <p>Finally, the same details should be present in some fashion in the XML report, in a way that Jenkins displays this information as well when drilling down into failed tests pages.</p>
  
  <p>If at all possible, I only care about printing this information when there are failed tests.</p>
  
  <p>How can I accomplish this? I've started looking into these options, but more guidance would be appreciated</p>
  
  <ul>
  <li>Custom JUnit reporter, runner or listener</li>
  <li>JUnit @Rules (Method/Class Rule, ErrorCollector, etc.)</li>
  <li>Using some special logger</li>
  <li>...</li>
  </ul>
  
  <p>PS. I'm not looking for a solution that simply writes such details to a separate file since the I consider the implications of that to be somewhat less user-friendly.</p>
  
  <p>Thanks!</p>