@SpringBootTest annotation in Spring Boot testing?@SpringBootTest tells Spring Boot to start the full application context for integration testing. It helps test how components work together in a real environment.
@SpringBootTest differ from unit testing annotations like @WebMvcTest?@SpringBootTest loads the entire application context, while @WebMvcTest loads only web layer components for focused controller tests.
webEnvironment attribute in @SpringBootTest control?It controls how the embedded web server is started during tests. Options include MOCK (no real server), RANDOM_PORT, DEFINED_PORT, and NONE.
@SpringBootTest for simple unit tests?Because it loads the full application context, which is slow and resource-heavy. For simple unit tests, use lighter annotations or plain JUnit tests.
@SpringBootTest to run tests with a specific profile?<p>You can add <code>@ActiveProfiles("test")</code> on the test class to activate the <code>test</code> profile during the test run.</p>@SpringBootTest do when placed on a test class?@SpringBootTest loads the full application context to test integration of components.
webEnvironment option starts a real server on a random port during @SpringBootTest?RANDOM_PORT starts an embedded server on a random port for real HTTP testing.
@SpringBootTest?@ActiveProfiles sets the active profile(s) for the test context.
@SpringBootTest tests run slower than unit tests?Loading the full application context takes more time and resources, slowing tests.
@WebMvcTest loads only web layer components for focused controller tests.
@SpringBootTest does and when you should use it.@SpringBootTest to run tests with a specific Spring profile and why this is useful.