Blog Archives

01: Mockito interview Q&As & examples on @Mock, @Spy, @Captor and @InjectMocks

Firstly, you need the pom.xml entry to bring in the Mockito library.

Read more ...


02: Mockito interview Q&As & examples on @Spy

A spy in mockito is a partial mock where part of the object will be mocked and part will use real method invocations. You can create a Spy a number of different ways. Consider using mocks instead of spies wherever possible as having to use a Spy could indicate violating…

Read more ...


03: Mockito interview Q&As & examples on @Mock, Mockito.mock(…) and @MockBean

Unlike a @Spy where you are spying on a real object, when you mock, you are creating a complete mock or fake object. Q: What are the different ways to mock an object? A: There are 3 ways to mock a dependent class that is sed by the class under…

Read more ...


04: Mockito interview Q&As & examples – PowerMock for mocking private & static methods

Let’s look at step by step to understand how to mock private & static methods with PowerMock & JUnit. pom.xml Step 1: The pom.xml file should have Mockito & Powermock libraries.

Read more ...


Don't be overwhelmed by the number of Q&As & tech stacks as nobody knows everything, and often key Q&As at the right moment makes a difference.

500+ Java Interview FAQs

Java & Big Data Tutorials

Top