Mockito
The most recommended of 8 testing frameworks
People recommend it as a Java mocking library that works well for testing code that does not use dependency injection, and many call it good enough for most cases. Critics warn that it encourages brittle tests and lazy design.
People recommend it as a Java mocking library that works well for testing code that does not use dependency injection, and many call it good enough for most cases. Critics warn that it encourages brittle tests and lazy design.
32 people gave an opinion
- recommend it
- 19
- criticize it
- 13
- approval share
- 59%
Recommended in 3 of 13 months
- November 2025: not recommended
- December 2025: recommended
- January 2026: not recommended
- February 2026: not recommended
- March 2026: recommended
- April 2026: not recommended
- May 2026: not recommended
- June 2026: not recommended
- July 2026: not recommended
- August 2026: not recommended
- September 2026: recommended
- October 2026: not recommended
- November 2026: not recommended (month in progress)
Owned for 4 years
Median of the 4 owners who said how long they have had it.
Each square is one year.
Why it doesn’t carry the badge
- 19 people recommend itNeeds 10 or more, met.
- 1.4 recommenders for every criticNeeds 2 to 1 or better, not met.
- Recommended in 3 of 13 monthsNeeds 4 or more, not met.
The same three rules apply to every product, and the badge can’t be bought. How the badge works
What people say about it
The reasons people give, with the number of comments that give each one. Open a reason to read what they said.
Why people recommend it
Each mark is one comment
Works for code without dependency injection
“Mockito has decent facilities for working with those, especially when you're working with a codebase that isn't pure DI and interfaces.”
Comment from 28 Dec 2025 in “Stepping down as Mockito maintainer after 10 years” “Mockito allows one to write mocks in tests for code that doesn't use dependency injection”
Comment from 28 Dec 2025 in “Stepping down as Mockito maintainer after 10 years” “Mockito, in every case I had to use it, was a last resort because a third party library didnt lend itself to mocking”
Comment from 29 Dec 2025 in “Stepping down as Mockito maintainer after 10 years” Good enough for most testing cases
“I've been using Mockito for about 4 years, all in Kotlin. I always found it to be "plenty good" for like 99% of the cases I needed it”
Comment from 29 Dec 2025 in “Stepping down as Mockito maintainer after 10 years” “"plenty good" for like 99% of the cases I needed it”
Comment from 28 Dec 2025 in “Stepping down as Mockito maintainer after 10 years” “I like Mockito, it's useful”
Comment from 29 Dec 2025 in “Stepping down as Mockito maintainer after 10 years” Useful when third-party libraries resist mocking
“Mockito, in every case I had to use it, was a last resort because a third party library didnt lend itself to mocking”
Comment from 29 Dec 2025 in “Stepping down as Mockito maintainer after 10 years” “The only way I was able to pull that off was using mocking”
Comment from 29 Dec 2025 in “Stepping down as Mockito maintainer after 10 years”
What people warn about
Each mark is one comment
Encourages bad habits and brittle tests
“Mocking encourages bad habits and a false sense of security.”
Comment from 28 Dec 2025 in “Stepping down as Mockito maintainer after 10 years” “tests depending on mocking are far more brittle”
Comment from 28 Dec 2025 in “Stepping down as Mockito maintainer after 10 years” “Mockito swoops in and prevents you from having that epiphany, by making it easier to keep doing things the stupid way.”
Comment from 29 Dec 2025 in “Stepping down as Mockito maintainer after 10 years” - Comment from 28 Dec 2025 in “Stepping down as Mockito maintainer after 10 years”
Overused for pointless unit tests
“Usually it is used for pointless unit tests of simple intermediary layers to test if call is delegated correctly”
Comment from 29 Dec 2025 in “Stepping down as Mockito maintainer after 10 years” “It allows you to mock the whole universe so it becomes a hammer instead of nicely designed functions, interfaces.”
Comment from 29 Dec 2025 in “Stepping down as Mockito maintainer after 10 years”
Other testing frameworks people recommend
The four most recommended other testing frameworks, with the same counts for each, so you can compare like for like. The tick on each bar marks the 2 to 1 line the badge needs.
| Product | Recommend | Criticize | Approval | Months | Owned | Badge |
|---|---|---|---|---|---|---|
| MockitoThis page | 19 | 13 | 59% | 3 | 4 yrs4 owners | — |
| cargo-nextest | 18 | 1 | 95% | 3 | — | — |
| Vitest | 17 | 8 | 68% | 8 | — | Approved |
| Testcontainers | 14 | 3 | 82% | 8 | — | Approved |
| pytest | 12 | 5 | 71% | 9 | — | Approved |
What people said
33 of the 35 comments that mention it, newest first. Each links to the original comment.
“Mockito (I bet it's the most common user of that feature)”
“You wanted Mockito to lead reality, but it lags it.”
“Spring Boot also often brings friends like MapStruct or Lombok or Mockito which add even more dynamic behavior and issues when you update JDK”
“Do you use Mockito or one of the myriad alternatives?”
“Usually it is used for pointless unit tests of simple intermediary layers to test if call is delegated correctly”
“I also often find the mocking DSL the better choice in tests.”
“Sounds like a problem that the Mockito team created for themselves, and like a problem only they can solve.”
“I spent some time replacing usages of it in Kafka test code with Mockito”
“It allows you to mock the whole universe so it becomes a hammer instead of nicely designed functions, interfaces.”
“avoided Mockito like GP, though it was occasionally useful”
“But I'm talking about people write new code this way”
“I like Mockito, it's useful”
“I've been using Mockito for about 4 years, all in Kotlin. I always found it to be "plenty good" for like 99% of the cases I needed it”
“Mockito did help me a lot through those times”
“The only way I was able to pull that off was using mocking”
“Mockito, in every case I had to use it, was a last resort because a third party library didnt lend itself to mocking”
“Mockito swoops in and prevents you from having that epiphany, by making it easier to keep doing things the stupid way.”
“tests depending on mocking are far more brittle”
“Mock is effective when developers keep applications at 4-5 layers deep”
“Mocking encourages bad habits and a false sense of security.”
“Spy's on the other hand, are a pain in the neck.”
“IMO Mockito is fine, the problem I’ve encountered is people taking the easy way out”
“So Mockito and friends are a nice alternative to that.”
“To create interfaces just for testing complicates the code and it is one of my pet peeves.”
“"plenty good" for like 99% of the cases I needed it”
“They also encourage/enable code that is less testable.”
“too many times have I really wanted mockito to also default to returning a mock instead of null”
“1000 line test setups that shatter into pieces the instant you try to make the simplest change to a function”
“Mockito was indeed a poor fit for Kotlin.”
“Mockito does one thing well as a name, and that is hinting strongly at what it is (a mocking library).”
“Mockito has decent facilities for working with those, especially when you're working with a codebase that isn't pure DI and interfaces.”
“Mockito allows one to write mocks in tests for code that doesn't use dependency injection”
“It’s taken years off of my life dealing with the test mess people have made with it.”
Counts come from 1,795,640 Hacker News comments, November 2025 to November 2026. How we count. Report a mistake.