File mockFile = createMockAndExpectNew(File.class, fileParentPath+fileName);
RandomAccessFile mockRandomAccessFile = createMockAndExpectNew(RandomAccessFile.class, mockFile, "rw");
mockRandomAccessFile.seek(0L);


我想为此预期的void方法设置调用计数,但是我不知道该怎么办。

最佳答案

要期待最后一次通话3次,可以使用expectLastCall方法:

// mockRandomAccessFile is a mock
mockRandomAccessFile.seek(0L);
EasyMock.expectLastCall().times(3);

10-06 14:59