Say I have a service:
UserService
And it has 2 public methods:
Method1, Method2
And I’m testing Method1, but Method1 makes a call to Method2.
How can I mock (or stub is the more correct word) the call to Method2.
If I mock UserService, that I can’t actually test Method1 now can I?
If I understand your question correctly, you can use
CallBase:Create your mock with
CallBase = true, setupMethod2to return whatever value you want to test with, and then callMethod1.As an example: