Skip to content

MockReset should be honored without @Mockito[Spy]Bean fields #33829

@sbrannen

Description

@sbrannen

As can be seen in the tests introduced in commit 4a0edc5, the static factory methods in MockReset (such as MockReset.before() and MockReset.after()) can currently only be applied to beans within the ApplicationContext if the test class declares at least one field annotated with either @MockitoBean or @MockitoSpyBean.

However, as stated in the Javadoc, it should be possible to apply MockReset:

directly to any mock in the ApplicationContext using the static methods in this class.

We therefore need to rework the "enabled" logic in MockitoResetTestExecutionListener to support that documented use case.

Metadata

Metadata

Assignees

Labels

in: testIssues in the test moduletheme: aotAn issue related to Ahead-of-time processingtype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions