Package io.mats3.spring.test
Annotation Interface SpringInjectRulesAndExtensions
@Target(TYPE)
@Retention(RUNTIME)
@TestExecutionListeners(listeners=SpringInjectRulesAndExtensionsTestExecutionListener.class,
mergeMode=MERGE_WITH_DEFAULTS)
@Documented
public @interface SpringInjectRulesAndExtensions
Use this Test Execution Listener to autowire JUnit Rules and Jupiter Extensions, i.e. so that any fields in the Rule
or Extension annotated with @Inject or @Autowire will be autowired - typically needed for
Rule_MatsEndpoint
and Extension_MatsEndpoint
.
To use, just put this annotation on the test class. If that fails, typically because you are also employing a
different TestExecutionListener, a fallback is to directly list the
SpringInjectRulesAndExtensions.SpringInjectRulesAndExtensionsTestExecutionListener
in the @TestExecutionListeners
annotation on
the test class, as such:
@TestExecutionListeners(listeners = SpringInjectRulesAndExtensionsTestExecutionListener.class, mergeMode = MergeMode.MERGE_WITH_DEFAULTS)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
ThisTestExecutionListener
finds all fields in the test class instance which is annotated with JUnitRule
or JUnit 5 JupiterRegisterExtension
, and runsbeanFactory.autowireBean(fieldValue)
on them.