# Spring Boot Testing (Spring Boot) > Spring Boot testing: @SpringBootTest, @WebMvcTest, @DataJpaTest, MockMvc, TestRestTemplate, test slices - 30 interview questions - Mid-Level - [Interview Questions: Spring Boot](https://sharpskill.dev/en/technologies/spring-boot/interview-questions.md) ## 1. Which annotation to use to load the full Spring Boot context for an integration test? **Answer** @SpringBootTest loads the full application context, including all beans and auto-configurations. This annotation is used for integration tests requiring the entire application. @WebMvcTest and @DataJpaTest only load part of the context (test slicing), while @ContextConfiguration is a lower-level annotation for manually configuring the context (more complex). ## 2. What is test slicing in Spring Boot? **Answer** Test slicing means loading only a specific part of the Spring context to speed up tests. For example, @WebMvcTest loads only web components (controllers, filters), while @DataJpaTest loads only JPA repositories. This reduces startup time and improves test performance by avoiding loading unnecessary beans. ## 3. Which annotation to use to test only a Spring MVC controller? **Answer** @WebMvcTest is specifically designed to test Spring MVC controllers. This annotation loads only web components (controllers, @ControllerAdvice, filters, interceptors) and automatically configures MockMvc. @SpringBootTest would load the entire context (unnecessary for testing a single controller), @DataJpaTest is for repositories, and @RestClientTest is for testing HTTP clients (RestTemplate, WebClient). ## 27 more questions available - What is the purpose of @MockBean in Spring Boot Test? - Which object to use to simulate HTTP requests in a test with @WebMvcTest? Sign up for free: https://sharpskill.dev/en/login ## Other Spring Boot interview topics - [Spring Core - IoC & DI](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/spring-core-ioc-di.md): 22 questions, Junior - [Spring Boot Auto-Configuration](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/spring-boot-auto-configuration.md): 20 questions, Junior - [Spring Boot Starters](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/spring-boot-starters.md): 18 questions, Junior - [Application Properties & YAML](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/application-properties-yml.md): 16 questions, Junior - [Logging with SLF4J & Logback](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/logging.md): 20 questions, Junior - [Spring Boot DevTools](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/spring-boot-devtools.md): 15 questions, Junior - [Spring MVC Basics](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/spring-mvc-basics.md): 20 questions, Mid-Level - [Spring REST Controllers](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/spring-rest-controllers.md): 20 questions, Mid-Level - [Request & Response Handling](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/request-response-handling.md): 20 questions, Mid-Level - [Exception Handling](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/exception-handling.md): 25 questions, Mid-Level - [Bean Validation](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/bean-validation.md): 25 questions, Mid-Level - [Spring Data JPA Basics](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/spring-data-jpa-basics.md): 25 questions, Mid-Level - [JPA Entities & Relationships](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/jpa-entities-relationships.md): 30 questions, Mid-Level - [JPA Queries](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/jpa-queries.md): 30 questions, Mid-Level - [Spring Data Repositories](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/spring-data-repositories.md): 25 questions, Mid-Level - [Spring Security Basics](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/spring-security-basics.md): 25 questions, Mid-Level - [Spring Boot Actuator](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/spring-boot-actuator.md): 20 questions, Mid-Level - [Unit Testing with JUnit & Mockito](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/testing-junit-mockito.md): 30 questions, Mid-Level - [Profiles & Environment](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/profiles-environment.md): 20 questions, Mid-Level - [RestTemplate & WebClient](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/resttemplate-webclient.md): 24 questions, Mid-Level - [Async & Scheduling](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/async-scheduling.md): 25 questions, Mid-Level - [Caching with Spring](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/caching.md): 25 questions, Mid-Level - [Spring WebFlux (Reactive)](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/spring-webflux.md): 25 questions, Mid-Level - [Spring Transactions](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/transactions.md): 30 questions, Senior - [Advanced Authentication & Authorization](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/authentication-authorization.md): 30 questions, Senior - [JWT & Stateless Security](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/jwt-stateless-security.md): 20 questions, Senior - [OAuth2 & Authorization Server](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/oauth2-authorization-server.md): 20 questions, Senior - [Spring Boot & Docker](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/spring-boot-docker.md): 19 questions, Senior - [Microservices with Spring](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/microservices-basics.md): 25 questions, Senior - [Spring Cloud Config](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/spring-cloud-config.md): 19 questions, Senior - [Performance Optimization](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/performance-optimization.md): 30 questions, Senior - [GraalVM Native Images](https://sharpskill.dev/en/technologies/spring-boot/interview-questions/graalvm-native-images.md): 20 questions, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/en/technologies/spring-boot/interview-questions/spring-boot-testing