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;

/**
 * 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 PrintStream getOriginalStream() { return err; } @Override void setStream(PrintStream wrappedLog) { setErr(wrappedLog); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy