Prev Next

Testing / Mockito Interview Questions

Mention a few Mockito Annotations.

  • @Mock used to create and inject mocked instances.
  • @Spy is used to create a real object and spy on the real object.
  • @Captor is used to create an ArgumentCaptor.
  • @InjectMocks is used to create an object of a class and insert its dependencies.
  • @RunWith keeps the test clean and improves debugging. It additionally detects the unutilized stubs available in the test and initializes mocks annotated with @Mock annotation.

More Related questions...

Show more question and Answers...


Comments & Discussions