Say I have a MyClass class with methods x() , y() and z() . Say x() calls y() and y() calls z() .
So every time I test x() , both y() and z() called. In case of abuse of the MyClass dependencies, I will have to mock the behavior of the dependencies inside x() , y() and z() .
So, if my tests for method x() are equal to testXWhen1() , testXWhen2() and testXWhen3() , I will have to repeat the expectations for my dependencies in each of the testing methods. In the end, I have code with expectations for what happens inside y() and z() , repeated for my three testing methods. Any solution to avoid this?
One of my ideas was to try and test the actual method x() , but taunt y() and z() . In this case, my MyClass instance should be partially mock and partially real MyClass . Is it possible?
Another solution was to be strict regarding expectations in x() , but not about what happens in y() and z() ... I think I can do this with @NonStrict instead of @Mocked , but that doesn't my favorite decision.
source share