Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the org.junit.contrib.java.lang.system.StandardOutputStreamLog?

Tags:

java

junit4

Where is this class? My project use the JUnit 4.12, and not found the StandardOutputStreamLog. Is it be removed at this release? or it come from the other lib? and what is the relation between these tow?

like image 282
Oolong Avatar asked Dec 31 '15 07:12

Oolong


2 Answers

SystemOutRule superseded StandardOutputStreamLog as suggested by @Rahul Tripathi.

Just adding few more pointers to get started right away.

Maven dependency:

<dependency>
    <groupId>com.github.stefanbirkner</groupId>
    <artifactId>system-rules</artifactId>
    <version>1.18.0</version>
    <scope>test</scope>
</dependency>

Add the jar to the buildpath to get the below import.

import org.junit.contrib.java.lang.system.SystemOutRule;

public void MyTest {
    @Rule
    public final SystemOutRule systemOutRule = new SystemOutRule().enableLog();

    @Test
    public void writesTextToSystemOut() {
        System.out.print("hello world");
        assertEquals("hello world", systemOutRule.getLog());
    }
}

Reference: http://stefanbirkner.github.io/system-rules/

like image 149
KurinchiMalar Avatar answered Oct 12 '22 19:10

KurinchiMalar


This class is deprecated and you should use SystemOutRule.

Check the source

StandardOutputStreamLog()

Deprecated.

Please use new SystemOutRule().enableLog().

Creates a rule that records writes while they are still written to the standard output stream.

like image 22
Rahul Tripathi Avatar answered Oct 12 '22 18:10

Rahul Tripathi