@ExtendWith(SpringExtention.class)
@ContextConfiguration(ConfigClass)
Are always used in combination.
@SpringJUnitConfig(ConfigClass)
Combines these two annotations into one annotation. Spring recommends using this annotation instead of the two.
If you don’t want to include a configuration class as an argument to @SpringJUnitConfig
You can also specify a Test configuration class nested inside
@SpringJUnitConfig. Then Spring will look for config class inside the class annotated with @SpringJUnitConfig
This is important when we want specific configurations only for a particular test class. E.g, we may want a specific DataSource for a particular test class
@SpringJUnitWebConfig is a composed annotation that combines
@ExtendWith(SpringExtension.class)
@ContextConfiguration and
@WebAppConfiguration from the Spring TestContext Framework.
You can use it at the class level as a drop-in replacement for @ContextConfiguration and @WebAppConfiguration.
@SpringJUnitWebConfig combines the same annotations of @SpringJUnitConfig plus the @WebAppConfiguration from Spring testing – to load the WebApplicationContext.