I'd like to use Spring profile groups in fast ContextConfiguration unit tests.
Given the following application.yaml definition in test scope and profile configuration classes:
spring:
profiles:
default: test-default
group:
h2:
- test-default
- database
- h2
and configuration classes like
@Configuration
@EnableJpaRepositories(basePackageClasses = [OrderRepository::class] )
@EnableTransactionManagement
@EntityScan( basePackageClasses = [ OrderEntity::class])
@Profile("database")
class DatabaseConfiguration {}
I'd like to write a fast test with (@ContextConfiguration) e.g.
@ActiveProfiles("h2", "database", "test-default")
@ContextConfiguration( classes = [TestDefaultConfiguration::class])
internal class DbIngestionEventHandlerIntegrationTest()
I have to define both, h2 and database profiles, because ContextConfiguration does not load the application.yaml.
Is it possible to define spring profile groups programmatically? - so that they can be reused in tests?