Say I have a class
class SomeClass { public void methodA() {} public void methodB() {} public void someMethod() { methodA(); methodB(); } }
I would like to check the behavior of someMethod () with Mockito.
The only way I could think of is to use spy ();
Something like
SomeClass someClass = spy(new SomeClass()); someClass.someMethod(); InOrder inOrder = inOrder(someClass); inOrder.verify(someClass).methodA(); inOrder.verify(someClass).methodB();
I am new to mockito and the documentation says
"Real spies should be used carefully and sometimes, for example, when working with outdated code."
So maybe I missed something, and there is a better (correct) way to check if methods A and methodB are called without explicitly naming them in the test case.
Thanks.
java unit-testing mockito
ank
source share