Add value attribute alias to @⁠MockitoBean and @⁠MockitoSpyBean

This commit improves the user experience for common use cases by
introducing new `value` attributes in @⁠MockitoBean and
@⁠MockitoSpyBean that are aliases for the existing `name` attributes.

For example, this allows developers to declare
@⁠MockitoBean("userService") instead of @⁠MockitoBean(name =
"userService"), analogous to the existing name/value alias support in
@⁠TestBean.

Closes gh-33680
This commit is contained in:
Sam Brannen
2024-10-10 13:05:33 +02:00
parent 1b8f2c46c1
commit 0e8316e704
12 changed files with 97 additions and 68 deletions

View File

@@ -77,7 +77,7 @@ Java::
[source,java,indent=0,subs="verbatim,quotes"]
----
class OverrideBeanTests {
@MockitoBean(name = "service") // <1>
@MockitoBean("service") // <1>
private CustomService customService;
// test case body...
@@ -121,7 +121,7 @@ Java::
[source,java,indent=0,subs="verbatim,quotes"]
----
class OverrideBeanTests {
@MockitoSpyBean(name = "service") // <1>
@MockitoSpyBean("service") // <1>
private CustomService customService;
// test case body...