How to clean up mocks in spring tests when using Mockito

前端 未结 4 2017
孤城傲影
孤城傲影 2020-12-25 11:30

I\'m pretty new to Mockito and have some trouble with clean up.

I used to use JMock2 for unit tests. As far as I know, JMock2 preserves the expectations and other mo

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-25 12:15

    Spring Boot has @MockBean annotation which you can use to mock your service. You don't need to reset mocks manually any more. Just replace @Autowired by @MockBean:

    @MockBean
    private PlaceOrderService placeOrderService;
    

提交回复
热议问题