-
Notifications
You must be signed in to change notification settings - Fork 38.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support @MockitoSpyBean
at the type level on test classes
#34408
Labels
Milestone
Comments
sbrannen
added a commit
to sbrannen/spring-framework
that referenced
this issue
Feb 11, 2025
This commit serves as a Proof of Concept. See spring-projectsgh-34408
This comment has been minimized.
This comment has been minimized.
sbrannen
added a commit
to sbrannen/spring-framework
that referenced
this issue
Feb 12, 2025
This commit serves as a Proof of Concept. See spring-projectsgh-34408
sbrannen
added a commit
to sbrannen/spring-framework
that referenced
this issue
Feb 12, 2025
sbrannen
added a commit
to sbrannen/spring-framework
that referenced
this issue
Feb 12, 2025
Prior to this commit, @MockitoSpyBean could only be declared on fields within test classes, which prevented developers from being able to easily reuse spy configuration across a test suite. With this commit, @MockitoSpyBean is now supported at the type level on test classes, their superclasses, and interfaces implemented by those classes. @MockitoSpyBean is also supported on enclosing classes for @Nested test classes, their superclasses, and interfaces implemented by those classes, while honoring @NestedTestConfiguration semantics. In addition, @MockitoSpyBean: - has a new `types` attribute that can be used to declare the type or types to spy when @MockitoSpyBean is declared at the type level - can be declared as a repeatable annotation at the type level - can be declared as a meta-annotation on a custom composed annotation which can be reused across a test suite (see the @SharedSpies example in the reference manual) To support these new features, this commit also includes the following changes. - MockitoSpyBeanOverrideProcessor has been revised to support @MockitoSpyBean at the type level. - The "Bean Overriding in Tests" and "@MockitoBean and @MockitoSpyBean" sections of the reference manual have been fully revised. See spring-projectsgh-34408 Closes spring-projectsgh-33925
sbrannen
added a commit
that referenced
this issue
Feb 12, 2025
Prior to this commit, @MockitoSpyBean could only be declared on fields within test classes, which prevented developers from being able to easily reuse spy configuration across a test suite. With this commit, @MockitoSpyBean is now supported at the type level on test classes, their superclasses, and interfaces implemented by those classes. @MockitoSpyBean is also supported on enclosing classes for @Nested test classes, their superclasses, and interfaces implemented by those classes, while honoring @NestedTestConfiguration semantics. In addition, @MockitoSpyBean: - has a new `types` attribute that can be used to declare the type or types to spy when @MockitoSpyBean is declared at the type level - can be declared as a repeatable annotation at the type level - can be declared as a meta-annotation on a custom composed annotation which can be reused across a test suite (see the @SharedSpies example in the reference manual) To support these new features, this commit also includes the following changes. - MockitoSpyBeanOverrideProcessor has been revised to support @MockitoSpyBean at the type level. - The "Bean Overriding in Tests" and "@MockitoBean and @MockitoSpyBean" sections of the reference manual have been fully revised. See gh-34408 Closes gh-33925
Closed via e31ce35 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Overview
As a followup to #33925, we should investigate the feasibility of supporting
@MockitoSpyBean
at the type level on test classes.A member of the community has expressed an interest in #33925 (comment), and there are additional up-votes on the comment.
Related Issues
@MockitoBean
at the type level on test classes #33925The text was updated successfully, but these errors were encountered: