You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know that @mock and MockedStatic can be used together. However there's no mentioning in the official documentation about MockedConstruction injection via @mock.
DefaultOrderRepository is used in the OrderService:
@RequiredArgsConstructor
public class OrderService {
private final OrderRepository orderRepository = new DefaultOrderRepository();
public List<Order> findAll() {
return orderRepository.findAll();
}
And after that I tried to mock some of DefaultOrderRepository methods:
OrderService service = new OrderService();
DefaultOrderRepository repository2 = repository.constructed().get(0);
when(repository2.findAll()).thenReturn(List.of());
and discovered that repository2 is not a mock but just a usual object. And when-thenReturn does nothing. So is this feature supported or not?
The text was updated successfully, but these errors were encountered:
Hi
I know that @mock and MockedStatic can be used together. However there's no mentioning in the official documentation about MockedConstruction injection via @mock.
Let's say I tried to inject that:
DefaultOrderRepository is used in the OrderService:
And after that I tried to mock some of DefaultOrderRepository methods:
and discovered that repository2 is not a mock but just a usual object. And when-thenReturn does nothing. So is this feature supported or not?
The text was updated successfully, but these errors were encountered: