【发布时间】:2020-02-21 10:35:47
【问题描述】:
@Test
public void testTotalMarks(){
Mark gMark = fakeMarkGenerator.createMarks();
DBMark dbMark = markMapper.toDBMark(gMark);
when(repoLayer.findMarksByStudentId()).thenReturn(Optional.of(dbMark));
markService.createMarks(gMark); //Actually createMarks method return type is DBMark.
//But this code works fine.
//Shouldn't this be DBMark dbMark2 = markService.createMarks(gMark); ??
verify(mockMarkMapper, times(2)).toTotal(any(Total.class)); //I don't understand times here
Assert statement
}
【问题讨论】:
-
请发布您要测试的方法。
-
verify仅在使用times(x)时检查该方法是否被调用x次。它与结果的比较无关。