- Mocking is a way to test the functionality of a class in an isolation fashion.
- When we use mockito then we do not require a database connection or file server read or properties file to read to test functionality.
- The mocking object usually does the mocking of the real service. A mock object usually returns a dummy data which corresponds to some dummy input passed to it.
- Mockito uses Java Reflection in order to create mock objects for a given interface. Mock objects are nothing but a proxy for actual implementations.
What is Mockito?
- The mockito is a very popular mocking framework and It is a java based library that is used for unit testing of any java applications.
- Mockito is usually used to mock interfaces so that a dummy method can be used for a mock interface that can be used in unit testing.
- The main use of using the Mockito framework is to simplify the development of a test case by mocking external dependencies and then use them in the test code.
NOTE: We can also use Mockito with other testing frameworks like JUnit and TestNG.
You May Also Like:
Why Need for mocking?
What are the Benefits of Mockito?
How to mock interface using Mockito example?
Mockito and JUnit Integration Using Maven Example
@Mock and @Spy Mockito Annotations With Example
@InjectMocks Annotation in Mockito with Example
Mockito – Verifying Method Calls
@Captor Annotation in Mockito with Example
Adding behavior to mocked object in Mockito
Mocking Void Methods with Mockito
Mocking Exception Throwing using Mockito
Mockito’s mock Overloaded Methods
That’s all about What is Mocking and Mockito?
If you have any feedback or suggestion please feel free to drop in below comment box.