@Test public void testStderrCaptureDetail() { ThreadLocalPrintStream.stderr(); System.err.println("1 - not captured, but next goes to capture only"); OutputCapturingContext capture = ThreadLocalPrintStream.stderr().capture(); final String TWO = "2 - captured"; System.err.println(TWO); Assert.assertEquals(TWO, capture.getOutputSoFar().trim()); String out = capture.end(); Assert.assertEquals(TWO, out.trim()); System.err.println("3 - not captured, restored normal output"); Assert.assertEquals(TWO, capture.getOutputSoFar().trim()); }
OutputCapturingContext stderr = ThreadLocalPrintStream.stderr().captureTee();