public class ConsoleWatcher extends org.junit.rules.TestWatcher implements AutoCloseable
public class Test {
&Rule
public ConsoleWatcher out = new ConsoleWatcher();
&Test
public void testOutput() {
System.err.println("woot!");
assertThat(out.error(), is("woot!\n"));
}
}
| Constructor and Description |
|---|
ConsoleWatcher() |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
ConsoleWatcher |
dumpErrorOnFailure()
Dump stderr to error output on failure.
|
ConsoleWatcher |
dumpOnFailure()
Dump both stdout and stderr to error output on failure.
|
ConsoleWatcher |
dumpOutputOnFailure()
Dump stdout to error output on failure.
|
String |
error() |
protected void |
failed(Throwable e,
org.junit.runner.Description description) |
protected void |
finished(org.junit.runner.Description description) |
ConsoleWatcher |
interactive()
Set input mode to interactive.
|
ConsoleWatcher |
nonInteractive()
Set input mode to non-interactive.
|
String |
output() |
void |
reset()
Reset all the streams for the console.
|
ConsoleWatcher |
setInput(byte[] in)
Set input to return the given bytes.
|
ConsoleWatcher |
setInput(Object... in)
Set input with dynamic content.
|
protected void |
starting(org.junit.runner.Description description) |
STTY |
tty() |
ConsoleWatcher |
withTerminalSize(int rows,
int cols)
Set the current terminal size.
|
public ConsoleWatcher withTerminalSize(int rows, int cols)
rows - Row count.cols - Column count.public ConsoleWatcher nonInteractive()
public ConsoleWatcher interactive()
public ConsoleWatcher dumpOutputOnFailure()
public ConsoleWatcher dumpErrorOnFailure()
public ConsoleWatcher dumpOnFailure()
public void reset()
public String output()
public String error()
public ConsoleWatcher setInput(@Nonnull byte[] in)
in - The bytes for input.public ConsoleWatcher setInput(Object... in)
in - The input values.public STTY tty()
public void close()
close in interface AutoCloseableprotected void starting(org.junit.runner.Description description)
starting in class org.junit.rules.TestWatcherprotected void failed(Throwable e, org.junit.runner.Description description)
failed in class org.junit.rules.TestWatcherprotected void finished(org.junit.runner.Description description)
finished in class org.junit.rules.TestWatcherCopyright © 2017. All rights reserved.