2017-10-16 7 views

答えて

1

System.outまたはSystem.errにログインしていると仮定すると、これらのストリームをキャプチャするためのJunit Rule Spring Bootがあります。

https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html#boot-features-output-capture-test-utility

スプリングドキュメントから例、働い

public class MyTest { 

    @Rule 
    public OutputCapture capture = new OutputCapture(); 

    @Test 
    public void testName() throws Exception { 
     System.out.println("Hello World!"); 
     assertThat(capture.toString(), containsString("World")); 
    } 
} 
+0

。ありがとう!!! – Anshuman

関連する問題