How to mock FileInputStream and other *Streams

前端 未结 5 1966
暖寄归人
暖寄归人 2021-01-14 11:47

I have class that gets GenericFile as input argument reads data and does some additional processing. I need to test it:

public class RealCardParser {

    pu         


        
5条回答
  •  悲&欢浪女
    2021-01-14 11:57

    Maybe this is a bad idea, but my first approach would have been creating an actual test-file rather than mocking the stream object.

    One could argue that this would test the GenericFile class rather than the getBufferedReader method.

    Maybe an acceptable way would be to return an actually existing test-file through the mocked GenericFile for testing the getBufferedReader?

提交回复
热议问题