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

org.junit.contrib.java.lang.system.StandardErrorStreamLog 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.err;
import static java.lang.System.setErr;

import java.io.PrintStream;

import org.junit.contrib.java.lang.system.internal.PrintStreamLog;

/**
 * The {@code StandardErrorStreamLog} captures writes to the standard error
 * stream. The text written is available via {@link #getLog()}.
 * 
 * 
 *   public void MyTest {
 *     @Rule
 *     public final StandardErrorStreamLog log = new StandardErrorStreamLog();
 * 
 *     @Test
 *     public void overrideProperty() {
 *       System.err.print("hello world");
 *       assertEquals("hello world", log.getLog());
 *     }
 *   }
 * 
*/ public class StandardErrorStreamLog extends PrintStreamLog { @Override protected PrintStream getOriginalStream() { return err; } @Override protected void setStream(PrintStream wrappedLog) { setErr(wrappedLog); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy