//预设当 iterator 调用 next()时第一次返回 hello,第 n 次都返
when(iterator.next()).thenReturn("hello").thenReturn("worl
String result = iterator.next() + " " + iterator.n
ext() + " " + iterator.next();
assertEquals("hello world world",result);
}
@Test(expected = IOException.class)
public void when_thenThrow() throws IOException {
OutputStream outputStream = mock(OutputStream.class);
OutputStreamWriter writer = new OutputStreamWriter(out
putStream);
doThrow(new IOException()).when(outputStream).close();
public void with_arguments(){