Code Snippet

Just another Code Snippet site

[JUnit] Test System.err and System.out content

public class TestClass {

    @Rule
    public final StandardErrorStreamLog logErr = new StandardErrorStreamLog();
 
    @Rule
    public final StandardOutputStreamLog log = new StandardOutputStreamLog();

    @Test
    public void test1()  {
	System.err.print("hello world");
	assertEquals("hello world", logErr.getLog());
    }
}

Maven dependency :

<dependency>
  <groupId>com.github.stefanbirkner</groupId>
  <artifactId>system-rules</artifactId>
  <version>1.5.0</version>
</dependency>


Comments are currently closed.