What is mockito-inline and how does it work to mock final methods?
Asked Answered
T

1

28

Javadocs in Mockito says - "Starting with version 2.7.6, we offer the 'mockito-inline' artifact that enables inline mock making without configuring the MockMaker extension file". What does this mean? How does mockito-inline works ? Why a separate artifact for mockito-inline?

Tower answered 13/11, 2018 at 5:36 Comment(0)
D
14

I stumbled upon this too and the answer is buried quite deep in the docs, so here it is.

Mockito optionally offers advanced mocking features like mocking final classes. For this to work, they use a different mechanism ("mock maker") that is considered experimental and therefore turned off by default. But:

As a convenience, the Mockito team provides an artifact where this mock maker is preconfigured. Instead of using the mockito-core artifact, include the mockito-inline artifact in your project.

Delay answered 1/2, 2021 at 17:48 Comment(1)
Since v5 Mockito uses mokito-inline by default: Mockito 5 switches the default mockmaker to mockito-inline, and now requires Java 11.Washout

© 2022 - 2024 — McMap. All rights reserved.