public class Sout {
public void hi(){
System.out.println(“hi”);
}
}
이렇게 콘솔에 어떤 메시지를 출력하는 경우가 있을 때 저걸 애플리케이션에서 캡춰할 수 있는 걸 만들어 보는 과제가 떨어졌다.
public class SoutTest {
SoutInterceptor soutInterceptor = new SoutInterceptor();
@Test
public void sout() throws IOException {
soutInterceptor.active();
Sout sout = new Sout();
sout.hi();
assertThat(