Photo by Birgith Roosipuu on Unsplash

Mockito Versus BDDMockito

Why Are There Two Classes to Do the Same Job?

Kenneth Kousen
7 min readApr 19, 2023

--

https://pragprog.com/newsletter/

If you take a look at the Javadocs for the Mockito testing framework, you’ll see that there are two separate classes to do most of the work: org.mockito.Mockito and its subclass org.mockito.BDDMockito. Having two classes with essentially the same API seems unnecessarily confusing. Which one are you supposed to use? Is either better than the other? Without any guidance, a newcomer to the framework can be faced with the paradox of choice: too many choices raises your anxiety level, at times to the point where you decide not to use anything. In this article, we’ll alleviate Mockito decision anxiety by helping you decide which way to go.

For those of you who prefer the video version:

If you’d rather see the discussion in text form, please read on. :)

People In Space

--

--

Kenneth Kousen
The Pragmatic Programmers

Author of the books Mockito Made Clear, Help Your Boss Help You, Kotlin Cookbook, Modern Java Recipes, Gradle Recipes for Android, and Making Java Groovy