Mocking Java InputStream

前端 未结 10 1682
既然无缘
既然无缘 2020-11-29 04:40

Please provide pointers to help me mock that java InputStream object. This is the line of code that I would wish to Mock:

InputStreamReader inputData = new I         


        
10条回答
  •  死守一世寂寞
    2020-11-29 05:01

    You could just use a ByteArrayInputStream and fill it with your test data.

    @Brad's example from the comments:

    InputStream anyInputStream = new ByteArrayInputStream("test data".getBytes());
    

提交回复
热议问题