---
title: "What's the best mock framework for Java?"  
description: "What's the best mock framework for Java?"  
author: "Anonymous User"  
published: 2015-07-23  
updated: 2015-07-23  
canonical: https://www.mindstick.com/forum/23366/what-s-the-best-mock-framework-for-java  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# What's the best mock framework for Java?

What's the best [framework](https://www.mindstick.com/forum/34615/software-framework-vs-library) for creating [mock](https://yourviews.mindstick.com/view/82642/how-helpful-are-mock-test-and-test-series-at-mppsc-coaching-institutes) [objects](https://www.mindstick.com/forum/145447/what-are-objects) in [Java](https://www.mindstick.com/articles/12214/web-development-company-in-india-laid-on-the-foundation-of-concrete-java-programming)? Why? What are the [pros and cons](https://www.mindstick.com/blog/11048/pros-and-cons-of-hadoop-system) of each framework?

## Replies

### Reply by Anonymous User

I've had good success using [Mockito](https://github.com/mockito/mockito)..\
When I tried learning about JMock and EasyMock, I found the learning curve to be a bit steep (though maybe that's just me).\
I like Mockito because of its simple and clean syntax that I was able to grasp pretty quickly. The minimal syntax is designed to support the common cases very well, although the few times I needed to do something more complicated I found what I wanted was supported and easy to grasp.\
Here's an (abridged) example from the Mockito homepage:\

```
import static org.mockito.Mockito.*;List mockedList = mock(List.class);mockedList.clear();verify(mockedList).clear();
```

It doesn't get much simpler than that.\
The only major downside I can think of is that it won't mock static methods.


---

Original Source: https://www.mindstick.com/forum/23366/what-s-the-best-mock-framework-for-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
