![JAR search and dependency download from the Maven repository](/logo.png)
org.junit.contrib.java.lang.system.StandardOutputStreamLog Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of system-rules Show documentation
Show all versions of system-rules Show documentation
A collection of JUnit rules for testing code which uses java.lang.System.
package org.junit.contrib.java.lang.system;
import static java.lang.System.out;
import static java.lang.System.setOut;
import java.io.PrintStream;
import org.junit.contrib.java.lang.system.internal.PrintStreamLog;
/**
* The {@code StandardOutputStreamLog} captures writes to the standard output
* stream. The text written is available via {@link #getLog()}.
*
*
* public void MyTest {
* @Rule
* public final StandardOutputStreamLog log = new StandardOutputStreamLog();
*
* @Test
* public void overrideProperty() {
* System.out.print("hello world");
* assertEquals("hello world", log.getLog());
* }
* }
*
*/
public class StandardOutputStreamLog extends PrintStreamLog {
@Override
protected PrintStream getOriginalStream() {
return out;
}
@Override
protected void setStream(PrintStream wrappedLog) {
setOut(wrappedLog);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy