When in a test class we instruct mockito
to providing some mock objects (annotating such attribute-fields with @Mock
) for the purpose of the testing (maybe to be injected into @InjectMocks
attribute-field), what are the rules being followed for creating each mock?
More specifically:
1) how is each mock being built?
2) how are the dependencies of each mock being handled? what rules and limitations should be considered when mocking?
3) The case "mocked class A depends on class B, and class B is in turn mocked (in the same test class)" is different from the case "mocked class A depends on class B and class B is not mocked"?