当我们在使用PowerMockito去mock一个方法的时候,如果方法入参包含不定参数,比如new Date()或者 Random(),这个时候就要用到 any.
- how to import it
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
- 单个参数
service1.select(any(Date.class))
- 多个参数,非any参数要用eq包起来
service1.select(eq(10), eq("ttt"), any(Date.class))