package console
Type Members
- class ConsoleWriter extends AnyRef
A test-friendly wrapper for the standard system output streams (System.out, System.err).
A test-friendly wrapper for the standard system output streams (System.out, System.err).
Ex:
class MyApp extends App { def run(): Unit = { val console = injector.instance[ConsoleWriter] console.out.println("Hello, World!") } }
- Note
Using the ConsoleWriter is preferred for testing because its state can be locally overridden/bound, where as using System.setOut() or System.setErr() modifies global state of the JVM, which may result in flaky tests.