Where is the org.junit.contrib.java.lang.system.StandardOutputStreamLog?
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/
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.
StandardOutputStreamLog() is not deprecated. It's a class that's not present in the JUnit 4.x package. I google this class plus the word maven like so : org.junit.contrib.java.lang.system.StandardOutputStreamLog() + maven and I found that it is not define in the junit Maven Repository but instead in the com.github.stefanbirkner. So by adding the maven coordinate
<dependency>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>system-rules</artifactId>
<version>1.16.0</version>
</dependency>
You should be able to resolve the problem.