Register AssertablePublishedEvents
in test ApplicationContext
if AssertJ is on the classpath
#1110
Labels
Milestone
Currently used spring-modulith version: 1.2.4
We're using JGiven for our tests to generate additional documentation.
When using JGiven with Spring, BDD style test steps are located inside stage classes which can then have Spring beans injected into them via
@Autowired
.As an aside, JGiven also does not support per-class test lifecycles and requires adding the stages as beans into the test context. As such, it would be nice if
@ApplicationModuleTest
would allow for additional include filters to be set. As of now, I have to@Import
the stages individually.Example:
The above test works, because the ModuleContextCustomizerFactory does register PublishedEvents on the application context (https://github.com/spring-projects/spring-modulith/blob/1.2.9/spring-modulith-test/src/main/java/org/springframework/modulith/test/ModuleContextCustomizerFactory.java#L89). However, I'm using AssertJ and would like to use the
AssertablePublishedEvents
API. But this only can be injected as a parameter into the test methods and is not registered on the application context.Would it be possible to detect the presence of AssertJ in the context customizer and register an AssertablePublishedEvents bean if AssertJ is present?
The text was updated successfully, but these errors were encountered: