Mockito 5.0.0 Released

submited by
Style Pass
2023-01-27 07:30:07

The venerable Java testing framework which allows the creation of test double objects in automated unit tests for the purpose of test-driven or behavior-driven development is going through a major update. Let's check what it offers.

When it comes to testing Java applications, there the two top testing libraries: JUnit and Mockito. While you write and execute your unit tests in JUnit, you need Mockito too to mock the costly dependencies used in your tests. These dependencies might be a database or a RESTful API; Mockito uses the constructs of stubs, mocks, and spies to do its job in replacing them.

Typically you use Mockito to generate fake classes for the dependencies and then define their responses when their methods get called. Then you do your testing by making sure that the objects you are currently testing interact as expected with the those mocked out classes.

Mockito is a mature library which after many iterations has reached version 5. It introduces some major changes starting with the version of Java it supports.

Leave a Comment