In order to integrate the spring-test capabilities into JUnit 5's Jupiter programming model, SpringExtension has been developed. This extension is part of the spring-test module, as of Spring 5. Let's see several examples of JUnit 5 and Spring 5 together.
Let’s suppose we want to make an integration in-container test of the Spring application described in the former section, made up of three classes: MySpringApplication, MessageComponent, and MessageService. As we have learned, in order to implement a Jupiter test against this application, we need to make the following steps:
- Annotate our test class with @ContextConfiguration to specify which ApplicationContext needs to be loaded.
- Annotate our test class with ...