Annotation Interface MockitoStrictness
Specifies the strictness level for all mocks created in a test class.
The MockStrictness annotation is used to configure the strictness behavior of Mockito mocks
within a test class. It allows developers to define how strictly Mockito should enforce the behavior
of mocks, such as verifying stubbed methods and detecting unused stubs or unexpected interactions.
This annotation can be applied to a test class to set the default Strictness level for all
mocks created by Mockito in that class. The strictness level can be one of the values defined in
Strictness, with the default being Strictness.STRICT_STUBS.
Strictness Levels:
Strictness.STRICT_STUBSEnsures that only stubbed methods are called and reports unused stubs.Strictness.WARN: (default) Warns about potential issues without failing the test.Strictness.LENIENT: Allows unstubbed calls and does not report unused stubs.
- See Also:
-
Strictness
-
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionorg.mockito.quality.StrictnessSpecifies the strictness level for all mocks in the test class.
-
Element Details
-
value
org.mockito.quality.Strictness valueSpecifies the strictness level for all mocks in the test class.- Returns:
- the
Strictnesslevel to apply to mocks, defaults toStrictness.STRICT_STUBS
-