@SpringBootTest
Learn @SpringBootTest (Spring MVC Testing, Spring MVC) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Fresher Notes @SpringBootTest loads the full application context, as if the app were started, so it tests real wiring of controllers, services and repositories. webEnvironment controls the server: MOCK (default, no real port), RANDOM_PORT and DEFINED_PORT start an embedded server. Slower than slices , so use it for a few end-to-end checks and use @WebMvcTest for most controller tests.