- PowerMockRunner的使用
@RunWith(PowerMockRunner.class)
- 静态类的Mock
@PrepareForTest(XXX.class)
PowerMockito.mockStatic(XXX.class)
- Spring类型单元测试
@PowerMockRunnerDelegate(SpringRunner.class)
@SpringBootApplication
@TestExecutionListeners(MockitoTestExecutionListener.class)
- Mock注解
//需要实际测试的服务
@InjectMocks
//提供mock的服务
@Mock
//模拟返回值
Mockito.when(X.X(Mockito.any())).thenReturn(obj);
来源:CSDN
作者:星空的未来
链接:https://blog.csdn.net/xkdwl12138/article/details/104639018