meeting-you / gitbook-commit

0 stars 0 forks source link

Mockito · 时光 笔记 #114

Open meeting-you opened 3 years ago

meeting-you commented 3 years ago

https://runing-time.github.io/book/doc/%E6%B5%8B%E8%AF%95/Mockito.html

meeting-you commented 3 years ago

在测试中,Mockito.anyList() 是不包含null的,其他引用类型也需要单独注意为null的情况

meeting-you commented 3 years ago

基本类型和对应的封装类型可看作一个类型

meeting-you commented 3 years ago

Mockito.when(mockitoTestService.getNum()).thenAnswer((Answer) invocation -> atomicInteger.incrementAndGet());
thenAnswer : 在每次执行时都会执行
Mockito.when(mockitoTestService.getNum2()).thenReturn(atomicInteger.incrementAndGet());
thenReturn : 固定值