What is Mockito in Software Testing Tool | Software Testing Tool
In this article, you will learn about the following:
- What is Mockito?
- What is Mocking Framework?
- Features of Mockito
What is Mockito?
It is a Java-based mocking framework is used in unit testing of applications. It plays an extremely important role in developing testable applications. It is released as a free and open-source framework under the license of MIT(Massachusetts Institute of Technology). It uses Java reflection API internally to generate the mock objects for a specific interface. Mock objects are considered proxy and dummy objects that are used in the actual implementation. The fundamental purpose of having a Mockito framework is to simplify the development of tests by mocking external dependencies and using the external dependencies in the test code. It gives a simpler test code that is so easy to catch, read, and modify. It can also be integrated with other software testing tools such as JUnit and TestNG. It was developed to upgrade the functionality of the EasyMock framework. It was developed by a huge team. The names of a few members from the team are Szczepan Faber, Brice Dutheil, Rafael Winterhalter, Tim van der Lippe, and others. Its latest version was released in August 2019 is 3.0.6.
What is Mocking Framework?
It is a process of developing the objects that are represented as a clone of real objects. In general, mocking is represented as a testing technique, where real objects are replaced by clone objects to perform the testing. Mock objects give the specific output of the particular input passed to it. The mocking technique or framework does not only work in Java Language but is used in any other Object-oriented programming language. There are multiple mocking techniques available, but the most famous technique is Mockito.
Features of Mockito:
- There is no need of writing the mock objects. It leads to no handwriting.
- It supports safe refactoring. It means do not change the test code while renaming the method name of the interface or interchanging the parameters.
- It allows an exception. The stack trace is used to find the cause of an exception.
- It uses annotations @Mock to create the mock objects.
- It gives the check on all the order of the method calls.


