You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, @TestBean factory methods must be defined in the test class, one of its superclasses, or in an implemented interface.
However, users may wish to define common factory methods in external classes that can be shared easily across multiple test classes simply by referencing an external method via a fully-qualified method name.
To align with the syntax used for fully-qualified method names in @MethodSource and fully-qualified field names in @FieldSource in JUnit Jupiter, I propose that we allow test bean factory methods to be referenced via a fully-qualified method name following the syntax <fully-qualified class name>#<method name>.
sbrannen
changed the title
Support external methods referened by fully-qualified method name in @TestBean
Support external methods referenced by fully-qualified name in @TestBeanJun 30, 2024
Prior to this commit, @TestBean factory methods had to be defined in
the test class, one of its superclasses, or in an implemented
interface. However, users may wish to define common factory methods in
external classes that can be shared easily across multiple test classes
simply by referencing an external method via a fully-qualified method
name.
To address that, this commit introduces support for referencing a
@TestBean factory method via its fully-qualified method name following
the syntax <fully-qualified class name>#<method name>.
Closesspring-projectsgh-33125
Overview
Currently,
@TestBean
factory methods must be defined in the test class, one of its superclasses, or in an implemented interface.However, users may wish to define common factory methods in external classes that can be shared easily across multiple test classes simply by referencing an external method via a fully-qualified method name.
Example
Given the following test utility...
... the following should be supported:
Proposal
To align with the syntax used for fully-qualified method names in
@MethodSource
and fully-qualified field names in@FieldSource
in JUnit Jupiter, I propose that we allow test bean factory methods to be referenced via a fully-qualified method name following the syntax<fully-qualified class name>#<method name>
.Related Issues
@TestBean
factory methods defined in interfaces #32943The text was updated successfully, but these errors were encountered: