In our Spring web applications, we use the Spring bean profiles to differentiate three scenarios: development, integration, and production. We use them to connect to differe
As other people have already pointed out, you can opt to use Maven to set the spring.profiles.active system property, making sure not to use @ActiveProfiles, but that's not convenient for tests run within the IDE.
For a programmatic means to set the active profiles, you have a few options.
ContextLoader that prepares the context by setting active profiles in the context's Environment.ContextLoader remains an option, but a better choice is to implement an ApplicationContextInitializer and configure it via the initializers attribute of @ContextConfiguration. Your custom initializer can configure the Environment by programmatically setting the active profiles.ActiveProfilesResolver API exactly for this purpose: to programmatically determine the set of active profiles to use in a test. An ActiveProfilesResolver can be registered via the resolver attribute of @ActiveProfiles.Regards,
Sam (author of the Spring TestContext Framework)