Create Mockito in Java authored by Derek Williams's avatar Derek Williams
Mockito is a testing utility that allows the programmer to create fake instances of an object.
Times where Mockito could be used is when a method connects to the database to fetch all online users. Instead of needing to talk to the database, we could use tell Mockito to just return a custom list.
# Table of Contents
1. [How do I mock something?](Mockito-in-Java#how-do-i-mock-something)
---
## How do I mock something?
Mocking objects in Java is fairly straight-forward in the beginning. The following code is how you would mock a Player.
In this example, the `Player` class contains two methods: `getName()` and `getAge()`.
<div align="center"><img src="img/mockito/how-to-mock.png"></div>
</p>
For a lot of cases, that's primarily all you'll need in JUnit tests. If you need something more advanced, keep reading.
---