All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.junit.contrib.java.lang.system.StandardOutputStreamLog Maven / Gradle / Ivy

There is a newer version: 1.19.0
Show newest version
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