In this tutorial, we will understand how to use Mockito framework. We will understand and implement the below topics.
Part 1 – What is Mockito?
In this tutorial, we will understand below topics –
– What is a Mock Object?
– When should I mock?
– Mockito Framework
– Enable Mockito Annotations
– How to Mock Object with @Mock & @InjectMock annotations in Spring application?
https://www.onlyfullstack.com/what-is-mock-object-what-is-mockito/
Part 2 – How to mock methods with Mockito?
ย – How to mock methods?
1. when/then
2. when/thenThrow
3. when/thenAnswer
https://www.onlyfullstack.com/how-to-mock-methods-with-mockito/
1. when/then
2. when/thenThrow
3. when/thenAnswer
https://www.onlyfullstack.com/how-to-mock-methods-with-mockito/
Part 3- How to mock void methods with Mockito
ย – Mocking Void Methods
–ย Three ways to mock the void method:
1. doNothing/when
2. doAnswer/when
3. doThrow/when
https://www.onlyfullstack.com/how-to-mock-void-methods-with-mockito/
ย – Mocking Void Methods
–ย Three ways to mock the void method:
1. doNothing/when
2. doAnswer/when
3. doThrow/when
https://www.onlyfullstack.com/how-to-mock-void-methods-with-mockito/
Part 4 – How to verify mocks in Mockito
–ย Simple verify method
–ย Variations in verify method
–ย Verify with the number of times
–ย Mockito Verify Order of Invocation
https://www.onlyfullstack.com/how-to-verify-the-mocks-in-mockito/
–ย Simple verify method
–ย Variations in verify method
–ย Verify with the number of times
–ย Mockito Verify Order of Invocation
https://www.onlyfullstack.com/how-to-verify-the-mocks-in-mockito/
Part 5 –ย Mockito Mock vs Spy
ย – Mockito Mock vs Spy
1. Object declaration
2. When the methods are not mocked
3. When the method is mocked
https://onlyfullstack.blogspot.com/2019/02/mockito-mock-vs-spy.html
1. Object declaration
2. When the methods are not mocked
3. When the method is mocked
https://onlyfullstack.blogspot.com/2019/02/mockito-mock-vs-spy.html

