- Written by JUnit Tester
- Category: Mockito
- Hits: 134
This is an HelloWorld tutorial about Mockito framework. In this tutorial we will show a basic example of Mockito, and how to verify some assertions on Mock objects.
Mocking provides a straightforward way to test the functionality of a class in isolation. As a matter of fact, you can simulate integration components such as database connections with Java components and still test a functionality. The component that simulates your service is called a Mock object and it returns a sample data corresponding to some dummy input passed to it.
Behind the hoods, Mockito facilitates creating mock objects by using Java Reflection in order to create mock objects for a given interface. Mock objects are just proxies for actual implementations.
Let's see a basic example of a Customer Service, defined by this interface: