java - Mockito: mock object in call hierarchy - chained call -
Is it possible to duplicate an object with mokto, which is said somewhere in the object hierarchy?
Let's consider the following sections:
@Component Class A @Autowired BB method get salary () call b.calculateSalary () @Component Class B @Autowired C C method is calculated () Call c.getDatabaseSalary () In the unit test, I would like to check the unit from received celebery
to class A
, but simulated same one In time, so that I change the value in lieu of getDatabaseSalary ()
when this method is called in the hierarchy.
You can do this with some changes in your design.
EDIT: Based on your comments, you are working on integration testing. Something like this will appear in the exam.
@ etowar private AA; @ Owned private BB; @ Mock private cc; @ Before public idle setup () (Mokitenation. Itmax ();} @Test Public Zero Test () {b. STC (c); when (c.getDatabaseSalary ()) thenReturn (...). A.obtainSalaryA ();}
Comments
Post a Comment