public class SystemOutputRule extends Object implements org.junit.rules.TestRule
System.out
or System.err
.
At the start of each test the System.out and System.err PrintStreams are replaced with ones that buffer data passed to them in memory, allowing the test to retrieve the contents of the buffer at any time and assert on it. At the end of the test the original PrintStreams are restored allowing access to the console again.
Constructor and Description |
---|
SystemOutputRule() |
Modifier and Type | Method and Description |
---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description) |
String |
getSystemErr() |
String |
getSystemOut() |
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
apply
in interface org.junit.rules.TestRule
public String getSystemOut()
public String getSystemErr()
Copyright © 2013. All Rights Reserved.