|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.junit.contrib.java.lang.system.StandardErrorStreamLog
SystemErrRule.
The StandardErrorStreamLog records writes to the standard error
stream. The text written is available via getLog().
public void MyTest {
@Rule
public final StandardErrorStreamLog log = new StandardErrorStreamLog();
@Test
public void captureErrorStream() {
System.err.print("hello world");
assertEquals("hello world", log.getLog());
}
}
You can clear the log if you only want to test parts of the text written to
the standard error stream.
@Test
public void captureErrorStream() {
System.err.print("before");
log.clear();
System.err.print("afterwards");
assertEquals("afterwards", log.getLog());
}
The test does not write to the stream if the rule is created with the
LogMode.LOG_ONLY mode.
@Rule public final StandardErrorStreamLog log = new StandardErrorStreamLog(LOG_ONLY);
@Deprecated public class StandardErrorStreamLog
| Constructor Summary | |
|---|---|
StandardErrorStreamLog()
Deprecated. Please use new SystemErrRule().enableLog().
Creates a rule that records writes while they are still written to the standard error stream. |
|
StandardErrorStreamLog(LogMode mode)
Deprecated. Please use new SystemErrRule().enableLog()
instead of
new StandardErrorStreamLog(LogMode.LOG_AND_WRITE_TO_STREAM) or
new SystemErrRule().enableLog().mute()
instead of new StandardErrorStreamLog(LogMode.LOG_ONLY).
Creates a rule that records writes to the standard error stream
according to the specified |
|
| Method Summary | |
|---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description)
Deprecated. |
void |
clear()
Deprecated. Please use SystemErrRule.clearLog().
Clears the log. The log can be used again. |
String |
getLog()
Deprecated. Please use SystemErrRule.getLog().
Returns the text written to the standard error stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StandardErrorStreamLog()
new SystemErrRule().enableLog().
Creates a rule that records writes while they are still written to the standard error stream.
public StandardErrorStreamLog(LogMode mode)
new SystemErrRule().enableLog()
instead of
new StandardErrorStreamLog(LogMode.LOG_AND_WRITE_TO_STREAM) or
new SystemErrRule().enableLog().mute()
instead of new StandardErrorStreamLog(LogMode.LOG_ONLY).
Creates a rule that records writes to the standard error stream
according to the specified LogMode.
mode - how the rule handles writes to the standard error stream.
NullPointerException - if mode is null.| Method Detail |
|---|
@Deprecated public void clear()
SystemErrRule.clearLog().
Clears the log. The log can be used again.
@Deprecated public String getLog()
SystemErrRule.getLog().
Returns the text written to the standard error stream.
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
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||