Add @MockitoBeanSettings, use MockitoSession with strict stubs default
This commit changes the way the `MockitoTestExecutionListener` sets up mockito, now using the `MockitoSession` feature. Additionally, stubbing now defaults to a STRICT mode which can be overruled with a newly introduced annotation: `@MockitoBeanSettings`. Closes gh-33318
This commit is contained in:
@@ -23,6 +23,9 @@ creating unnecessary contexts.
|
||||
====
|
||||
|
||||
Each annotation also defines Mockito-specific attributes to fine-tune the mocking details.
|
||||
During the test class lifecycle, Mockito is set up via the `Mockito#mockitoSession()`
|
||||
mechanism. Notably, it enables `STRICT_STUBS` mode by default. This can be changed on
|
||||
individual test classes with the `@MockitoBeanSettings` annotation.
|
||||
|
||||
The `@MockitoBean` annotation uses the `REPLACE_OR_CREATE_DEFINITION`
|
||||
xref:testing/testcontext-framework/bean-overriding.adoc#testcontext-bean-overriding-custom[strategy for test bean overriding].
|
||||
|
||||
Reference in New Issue
Block a user