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() |
String |
error() |
protected void |
failed(Throwable e,
org.junit.runner.Description description) |
protected void |
finished(org.junit.runner.Description description) |
String |
output() |
void |
reset()
Reset stream console.
|
void |
setInput(byte[] in)
Set input to return the given bytes.
|
void |
setInput(Object... in)
Set input with dynamic content.
|
void |
setInput(String in)
Set input to return the given string content.
|
ConsoleWatcher |
setTerminalSize(int rows,
int cols)
Set the current terminal size.
|
protected void |
starting(org.junit.runner.Description description) |
Terminal |
terminal(STTYMode mode)
Make a terminal for testing.
|
STTY |
tty() |
public void reset()
public String output()
public String error()
public void setInput(Object... in)
in - The input values.public ConsoleWatcher setTerminalSize(int rows, int cols)
rows - Row count.cols - Column countr.public void setInput(@Nonnull String in)
in - The string input.public void setInput(@Nonnull byte[] in)
in - The bytes for input.public STTY tty()
public Terminal terminal(STTYMode mode)
mode - The output mode of the terminal.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.