mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
41904d46ad
In order to be able to support parameter injection in @BeforeTransaction and @AfterTransaction methods (see gh-30736), this commit introduces a MethodInvoker API for TestExecutionListeners as a generic mechanism for delegating to the underlying testing framework to invoke methods. The default implementation simply invokes the method without arguments, which allows TestExecutionListeners using this mechanism to operate correctly when the underlying testing framework is JUnit 4, TestNG, etc. A JUnit Jupiter specific implementation is registered in the SpringExtension which delegates to the ExtensionContext.getExecutableInvoker() mechanism introduced in JUnit Jupiter 5.9. This allows a TestExecutionListener to transparently benefit from registered ParameterResolvers in JUnit Jupiter (including the SpringExtension) when invoking user methods, effectively providing support for parameter injection for arbitrary methods. Closes gh-31199