Class StdOutputStream

java.lang.Object
java.io.OutputStream
org.junitpioneer.jupiter.StdOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
Direct Known Subclasses:
StdErr, StdOut

abstract class StdOutputStream extends OutputStream
  • Field Details

  • Constructor Details

    • StdOutputStream

      public StdOutputStream()
  • Method Details

    • write

      public void write(int i)
      Specified by:
      write in class OutputStream
    • write

      public final void write(byte[] b, int off, int len)
      Overrides:
      write in class OutputStream
    • capturedString

      public String capturedString()
      Returns:
      the string that was written to System.out or System.err
    • capturedLines

      public String[] capturedLines()
      The capturedString(), divided on the line separator.

      This includes leading, inner, and trailing empty lines but does not include the potential empty string that comes after a trailing line separator. (The exact algorithm is based on but behaves differently from String.split(String).)

      Because the return value does not include a trailing empty line that comes from a trailing line separator, it can't be used to distinguish the cases where the last line was created by a print or a println. For more details and examples on this, see the documentation on standard input/output.

      Returns:
      the lines that were written to System.out or System.err