java.lang.Object
com.github.sbt.junit.jupiter.internal.listeners.OutputCapture

public class OutputCapture extends Object
Hijacks the systems standard output and error streams on a per-thread basis and redirects to given streams.
  • Constructor Details

    • OutputCapture

      public OutputCapture()
  • Method Details

    • install

      public static void install(StreamPair system)
      Possibly installs delegating print streams.

      Checks whether the current thread is the first thread to install output capturing. If true, the original print streams will be overwritten by custom, delegating print streams.

      In any case this method stores the specified system stream pair, so that it can be successfully restored later on.

      Parameters:
      system - A stream pair containing the original system streams.
      See Also:
    • uninstall

      public static void uninstall()
      Possibly restores the original print streams.

      Checks whether the current thread is the last thread which previously installed output capturing. If true, then the original print streams will be restored.

      See Also:
    • register

      public static void register(PrintStream out, PrintStream err)
      Register streams for the current thread.
      Parameters:
      out - The standard output stream which is to be registered.
      err - The error stream which is to be registered.
      Throws:
      IllegalStateException - If output capturing has not been installed.
    • deregister

      public static void deregister()
      Deregister streams for the current thread, and restore the previous if any.