请提供指针来帮助我模拟那个 java InputStream 对象.这是我希望模拟的代码行:
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 InputStreamReader(System.in);
bufferdReader = new BufferedReader(inputData);
bufferdReader.readLine();
BufferedReader bufferedReader = org.mockito.Mockito.mock(BufferedReader.class);
when(bufferedReader.readLine())
.thenReturn("first line")
.thenReturn("second line");
org.junit.Assert.when(new Client(bufferedReader).parseLine())
.thenEquals(IsEqual.equalTo("first line"));
这篇关于模拟 Java InputStream的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何模拟超级参考(在超级类上)?How to mock super reference (on super class)?(如何模拟超级参考(在超级类上)?)
Java 模拟数据库连接Java mock database connection(Java 模拟数据库连接)
Mockito ClassCastException - 无法投射模拟Mockito ClassCastException - A mock cannot be cast(Mockito ClassCastException - 无法投射模拟)
将值设置为模拟对象但获取 nullSet value to mocked object but get null(将值设置为模拟对象但获取 null)
如何模拟 DriverManager.getConnection(...)?How to mock DriverManager.getConnection(...)?(如何模拟 DriverManager.getConnection(...)?)
模拟;使用列表调用验证方法,忽略列表中元素的Mockito; verify method was called with list, ignore order of elements in list(模拟;使用列表调用验证方法,忽略列表中元素的顺序)