O'Reilly logo

Mastering Software Testing with JUnit 5 by Boni García

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mockito in a nutshell

As introduced in Chapter 1, Retrospective on Software Quality and Java Testing, there are different levels of software testing, such as unit, integration, system, or acceptance. Regarding unit tests, they should be executed in isolation for a single piece of software, for example, an individual class. The objective in this level of tests is to verify the functionality of the unit and not of its dependencies.

In other words, we want to test what is known as the System Under Test (SUT) but not its Depended-On Components (DOCs). To achieve this isolation, we use typically test doubles to replace these DOCs. Mock objects are a kind of test double, which are programmed with expectations about the real DOC.

In few words, Mockito ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required