Class StandardErrorStreamLog
java.lang.Object
org.junit.contrib.java.lang.system.StandardErrorStreamLog
- All Implemented Interfaces:
org.junit.rules.TestRule
Deprecated.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Please usenew SystemErrRule().enableLog().Deprecated.Please usenew SystemErrRule().enableLog()instead ofnew StandardErrorStreamLog(LogMode.LOG_AND_WRITE_TO_STREAM)ornew SystemErrRule().enableLog().mute()instead ofnew StandardErrorStreamLog(LogMode.LOG_ONLY). -
Method Summary
Modifier and TypeMethodDescriptionorg.junit.runners.model.Statementapply(org.junit.runners.model.Statement base, org.junit.runner.Description description) Deprecated.voidclear()Deprecated.Please useSystemErrRule.clearLog().getLog()Deprecated.Please useSystemErrRule.getLog().
-
Field Details
-
systemErrRule
Deprecated.
-
-
Constructor Details
-
StandardErrorStreamLog
public StandardErrorStreamLog()Deprecated.Please usenew SystemErrRule().enableLog().Creates a rule that records writes while they are still written to the standard error stream.
-
StandardErrorStreamLog
Deprecated.Please usenew SystemErrRule().enableLog()instead ofnew StandardErrorStreamLog(LogMode.LOG_AND_WRITE_TO_STREAM)ornew SystemErrRule().enableLog().mute()instead ofnew StandardErrorStreamLog(LogMode.LOG_ONLY).Creates a rule that records writes to the standard error stream according to the specified
LogMode.- Parameters:
mode- how the rule handles writes to the standard error stream.- Throws:
NullPointerException- ifmodeis null.
-
-
Method Details
-
clear
Deprecated.Please useSystemErrRule.clearLog().Clears the log. The log can be used again.
-
getLog
Deprecated.Please useSystemErrRule.getLog().Returns the text written to the standard error stream.
- Returns:
- the text written to the standard error stream.
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description) Deprecated.- Specified by:
applyin interfaceorg.junit.rules.TestRule
-
SystemErrRule.The
StandardErrorStreamLogrecords writes to the standard error stream. The text written is available viagetLog().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()); }Prevent output to the standard error stream
In general it is not necessary that a test writes to the standard error stream. Avoiding this output may speed up the test and reduce the clutter on the commandline.The test does not write to the stream if the rule is created with the
LogMode.LOG_ONLYmode.