This week's book giveaway is in the Agile forum.
We're giving away four copies of The Software Craftsman and have Sandro Mancuso on-line!
See this thread for details.
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 Software Craftsman this week in the Agile 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
Have you tried LearnNowOnline?
subject: Is Mockito like Junit?