mockito5.4.0单元测试(14) --捕获mock对象调用某方法时的参数ArgumentCaptor,断言其参数值
mockito官方文档地址: https://www.javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#resetting_mocks
@Test
public void test_resetting() {
//you can enable partial mock capabilities selectively on mocks:
LinkedList mock = mock(LinkedList.class);
when(mock.size()).thenReturn(10);
mock.add(1);
log.info("被mock的size = {}", mock.size()); // print: 被mock的size = 10
// reset重置mock对象的所有mock行为,比如thenReturn这种mock预设
reset(mock);
log.info("reset充值后的size = {}", mock.size()); // print: reset充值后的size = 0
}
end.
![](https://images.cnblogs.com/cnblogs_com/zhuwenjoyce/945554/o_201113020411my-zhifubao-shouqianma.jpeg)