@SpringJUnitConfig

Pubblicato il: 26 marzo 2024
sul canale di: JavaAnatomy
199
3

@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.


In questa pagina del sito puoi guardare il video online @SpringJUnitConfig della durata di ore minuti seconda in buona qualità , che l'utente ha caricato JavaAnatomy 26 marzo 2024, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 199 volte e gli è piaciuto 3 spettatori. Buona visione!