08-02-2023, 10:31 AM
I have a Service Class with 3 methods, Service class is also using some @Autowired annotations.
Out of 3 methods, I want to mock two methods but use real method for 3rd one.
Problem is:
1. If I am using @Autowired with @Spy, all three real method implementation is being called.
2. If I am using @Spy only, call to real method is return with Null pointer as there is no initialisation of Autowired objects.
Out of 3 methods, I want to mock two methods but use real method for 3rd one.
Problem is:
1. If I am using @Autowired with @Spy, all three real method implementation is being called.
2. If I am using @Spy only, call to real method is return with Null pointer as there is no initialisation of Autowired objects.