@SpringBootTest annotation in Spring Boot?@SpringBootTest tells Spring Boot to start the full application context for integration testing. It helps test how different parts of the app work together.
@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 starts during tests. Options include MOCK (no real server), RANDOM_PORT, DEFINED_PORT, or NONE.
@SpringBootTest considered slower than unit tests?Because it loads the full Spring application context, which takes more time than loading only small parts for unit tests.
@SpringBootTest to run tests with a random port?Use @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) to start the server on a random port for real HTTP testing.
@SpringBootTest do in a test class?@SpringBootTest loads the full Spring context to test integration of components.
webEnvironment option starts a real server on a random port?RANDOM_PORT starts the embedded server on a random port for HTTP tests.
@SpringBootTest tests run slower than unit tests?Loading the full Spring context takes more time than isolated unit tests.
@WebMvcTest loads only web layer beans for focused controller tests.
@SpringBootTest be used to test database integration?It loads the full context, so database integration can be tested.
@SpringBootTest does and when you would use it.@SpringBootTest and @WebMvcTest.