• Deprecated Classes
    Class
    Description
    Please use SystemErrRule.

    The StandardErrorStreamLog records writes to the standard error stream. The text written is available via StandardErrorStreamLog.getLog().

       public void MyTest {
         @Rule
         public final StandardErrorStreamLog log = new StandardErrorStreamLog();
    
         @Test
         public void captureErrorStream() {
           System.err.print("hello world");
           assertEquals("hello world", log.getLog());
         }
       }
     
    You can clear the log if you only want to test parts of the text written to the standard error stream.
       @Test
       public void captureErrorStream() {
         System.err.print("before");
         log.clear();
         System.err.print("afterwards");
         assertEquals("afterwards", log.getLog());
       }
     

    Prevent output to the standard error stream

    In general it is not necessary that a test writes to the standard error stream. Avoiding this output may speed up the test and reduce the clutter on the commandline.

    The test does not write to the stream if the rule is created with the LogMode.LOG_ONLY mode.

     @Rule
     public final StandardErrorStreamLog log = new StandardErrorStreamLog(LOG_ONLY);
    Please use SystemOutRule.

    The StandardOutputStreamLog records writes to the standard output stream. The text written is available via StandardOutputStreamLog.getLog().

       public void MyTest {
         @Rule
         public final StandardOutputStreamLog log = new StandardOutputStreamLog();
    
         @Test
         public void captureOutputStream() {
           System.out.print("hello world");
           assertEquals("hello world", log.getLog());
         }
       }
     
    You can clear the log if you only want to test parts of the text written to the standard output stream.
       @Test
       public void captureOutputStream() {
         System.out.print("before");
         log.clear();
         System.out.print("afterwards");
         assertEquals("afterwards", log.getLog());
       }
     

    Prevent output to the standard output stream

    In general it is not necessary that a test writes to the standard output stream. Avoiding this output may speed up the test and reduce the clutter on the commandline.

    The test does not write to the stream if the rule is created with the LogMode.LOG_ONLY mode.

     @Rule
     public final StandardOutputStreamLog log = new StandardOutputStreamLog(LOG_ONLY);