File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Testing and the fly likes Is Mockito like Junit? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Is Mockito like Junit?" Watch "Is Mockito like Junit?" New topic

Is Mockito like Junit?

Rogerio Kioshi
Ranch Hand

Joined: Apr 12, 2005
Posts: 689
I'd like to know if Mockito does the same thing JUnit does.

Tomek Kaczanowski
Ranch Hand

Joined: Oct 26, 2005
Posts: 40

Hi Rogerio,

the short answer is: no.

JUnit is a framework for writing and running tests (especially unit tests).
Mockito allows to create mocks (test doubles) which can replace real collaborators of a class, thus making it possible to implement some test cases.

JUnit and Mockito are often used together. JUnit is used to create the structure of test, while Mockito allow to specify some details of tests within the framework imposed by JUnit.

Please see and for more information.

Tomek Kaczanowski
Book author: Practical Unit Testing with TestNG and Mockito
It is sorta covered in the JavaRanch Style Guide.
subject: Is Mockito like Junit?