Performance: Test profiles and configuration
This concept affects application startup time and memory usage during testing by controlling which beans and configurations load.
@SpringBootTest @ActiveProfiles("test") public class UserServiceTest { // Loads only test-specific beans }
@SpringBootTest
public class UserServiceTest {
// No profile specified, loads all beans
}| Pattern | Beans Loaded | Startup Time | Memory Usage | Verdict |
|---|---|---|---|---|
| No profile specified | All beans | High (slow) | High | [X] Bad |
| @ActiveProfiles("test") used | Only test beans | Low (fast) | Low | [OK] Good |
testdb?application-{profile}.properties for profile-specific config files.testdb, the correct file name is application-testdb.properties.@ActiveProfiles("test")application.properties with db.url=prod-dbapplication-test.properties with db.url=test-dbdb.url during this test?application-test.properties override those in application.properties when 'test' profile is active.@ActiveProfiles("dev") but the test still uses properties from application.properties instead of application-dev.properties. What is the most likely cause?application-dev.properties is missing or named incorrectly, Spring Boot falls back to application.properties.application-dev.properties file is missing or misnamed -> Option Dintegration that uses a different database URL and disables security. Which combination correctly activates this profile and overrides the default settings?application-integration.properties to override database URL and security settings for the integration profile.@ActiveProfiles("integration") to activate the profile during test runs.application-integration.properties with overrides and annotate tests with @ActiveProfiles("integration") -> Option APass the test and this pattern moves unknown