Class | Description |
---|---|
org.junit.contrib.java.lang.system.StandardErrorStreamLog |
Please use
SystemErrRule .
The 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 streamIn 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
@Rule public final StandardErrorStreamLog log = new StandardErrorStreamLog(LOG_ONLY); |
org.junit.contrib.java.lang.system.StandardOutputStreamLog |
Please use
SystemOutRule .
The public void MyTest { @Rule public final StandardOutputStreamLog log = new StandardOutputStreamLog(); @Test public void captureOutputStream() { System.out.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 output stream. @Test public void captureOutputStream() { System.out.print("before"); log.clear(); System.out.print("afterwards"); assertEquals("afterwards", log.getLog()); } Prevent output to the standard output streamIn general it is not necessary that a test writes to the standard output 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
@Rule public final StandardOutputStreamLog log = new StandardOutputStreamLog(LOG_ONLY); |
Enum | Description |
---|---|
org.junit.contrib.java.lang.system.LogMode |
This enum is no longer needed, because all rules that are using
it have been replaced with rules that don't need the enum.
Mode of the
|
Constructor | Description |
---|---|
org.junit.contrib.java.lang.system.ProvideSystemProperty() | |
org.junit.contrib.java.lang.system.RestoreSystemProperties(String...) |
Please use
RestoreSystemProperties() . The
rule restores all properties. That's why you don't have to
specify the properties anymore. |
org.junit.contrib.java.lang.system.StandardErrorStreamLog() |
Please use
new SystemErrRule().enableLog() .
Creates a rule that records writes while they are still written to the standard error stream. |
org.junit.contrib.java.lang.system.StandardOutputStreamLog() |
Please use
new SystemOutRule().enableLog() .
Creates a rule that records writes while they are still written to the standard output stream. |
org.junit.contrib.java.lang.system.TextFromStandardInputStream(String) |
Enum Constant | Description |
---|---|
org.junit.contrib.java.lang.system.LogMode.LOG_AND_WRITE_TO_STREAM |
Please use
SystemErrRule.enableLog() or
SystemOutRule.enableLog() .
Record the writes while they are still written to the stream. |
org.junit.contrib.java.lang.system.LogMode.LOG_ONLY |
Please use
SystemErrRule.enableLog() .mute() or
SystemOutRule.enableLog() .mute() .
Capture the writes to the stream. Nothing is written to the stream itself. |
Copyright © 2011–2018. All rights reserved.