# Spring Boot 테스트 (Spring Boot) > Spring Boot 테스트: @SpringBootTest, @WebMvcTest, @DataJpaTest, MockMvc, TestRestTemplate, 테스트 슬라이스 - 30 면접 질문 - Mid-Level - [면접 질문: Spring Boot](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions.md) ## 1. 통합 테스트에서 Spring Boot의 전체 컨텍스트를 로드하려면 어떤 어노테이션을 사용합니까? **답변** @SpringBootTest는 모든 bean과 자동 구성을 포함하여 애플리케이션의 전체 컨텍스트를 로드합니다. 이 어노테이션은 애플리케이션 전체가 필요한 통합 테스트에 사용됩니다. @WebMvcTest와 @DataJpaTest는 컨텍스트의 일부만 로드하며(테스트 슬라이싱), @ContextConfiguration은 컨텍스트를 수동으로 구성하기 위한 더 낮은 수준의 어노테이션입니다(더 복잡함). ## 2. Spring Boot에서 테스트 슬라이싱(test slicing)이란 무엇입니까? **답변** 테스트 슬라이싱은 테스트 속도를 높이기 위해 Spring 컨텍스트의 특정 부분만 로드하는 것을 의미합니다. 예를 들어 @WebMvcTest는 web 컴포넌트(controller, filter)만 로드하고, @DataJpaTest는 JPA repository만 로드합니다. 이를 통해 시작 시간이 줄어들고 불필요한 bean 로딩을 피해 테스트 성능이 향상됩니다. ## 3. Spring MVC controller만 테스트하려면 어떤 어노테이션을 사용합니까? **답변** @WebMvcTest는 Spring MVC controller를 테스트하기 위해 특별히 설계되었습니다. 이 어노테이션은 web 컴포넌트(controller, @ControllerAdvice, filter, interceptor)만 로드하고 MockMvc를 자동으로 구성합니다. @SpringBootTest는 전체 컨텍스트를 로드하며(단일 controller 테스트에는 불필요), @DataJpaTest는 repository용, @RestClientTest는 HTTP 클라이언트(RestTemplate, WebClient) 테스트용입니다. ## 27개 추가 질문 이용 가능 - Spring Boot Test에서 @MockBean 어노테이션의 목적은 무엇입니까? - @WebMvcTest를 사용한 테스트에서 HTTP 요청을 시뮬레이션하려면 어떤 객체를 사용합니까? 무료로 가입하기: https://sharpskill.dev/ko/login ## 기타 Spring Boot 면접 주제 - [Spring Core - IoC & DI](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/spring-core-ioc-di.md): 22개 질문, Junior - [Spring Boot Auto-Configuration](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/spring-boot-auto-configuration.md): 20개 질문, Junior - [Spring Boot Starters](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/spring-boot-starters.md): 18개 질문, Junior - [Application Properties & YAML](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/application-properties-yml.md): 16개 질문, Junior - [SLF4J 및 Logback을 사용한 로깅](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/logging.md): 20개 질문, Junior - [Spring Boot DevTools](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/spring-boot-devtools.md): 15개 질문, Junior - [Spring MVC Basics](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/spring-mvc-basics.md): 20개 질문, Mid-Level - [Spring REST Controllers](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/spring-rest-controllers.md): 20개 질문, Mid-Level - [Request & Response Handling](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/request-response-handling.md): 20개 질문, Mid-Level - [예외 처리](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/exception-handling.md): 25개 질문, Mid-Level - [Bean Validation](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/bean-validation.md): 25개 질문, Mid-Level - [Spring Data JPA 기초](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/spring-data-jpa-basics.md): 25개 질문, Mid-Level - [JPA 엔티티 및 관계](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/jpa-entities-relationships.md): 30개 질문, Mid-Level - [JPA 쿼리](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/jpa-queries.md): 30개 질문, Mid-Level - [Spring Data Repositories](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/spring-data-repositories.md): 25개 질문, Mid-Level - [Spring Security 기초](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/spring-security-basics.md): 25개 질문, Mid-Level - [Spring Boot Actuator](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/spring-boot-actuator.md): 20개 질문, Mid-Level - [JUnit과 Mockito를 사용한 단위 테스트](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/testing-junit-mockito.md): 30개 질문, Mid-Level - [Profiles와 Environment](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/profiles-environment.md): 20개 질문, Mid-Level - [RestTemplate 및 WebClient](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/resttemplate-webclient.md): 24개 질문, Mid-Level - [Async와 스케줄링](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/async-scheduling.md): 25개 질문, Mid-Level - [Spring을 사용한 캐싱](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/caching.md): 25개 질문, Mid-Level - [Spring WebFlux (리액티브)](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/spring-webflux.md): 25개 질문, Mid-Level - [Spring 트랜잭션](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/transactions.md): 30개 질문, Senior - [고급 인증 및 인가](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/authentication-authorization.md): 30개 질문, Senior - [JWT 및 스테이트리스 보안](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/jwt-stateless-security.md): 20개 질문, Senior - [OAuth2와 Authorization Server](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/oauth2-authorization-server.md): 20개 질문, Senior - [Spring Boot와 Docker](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/spring-boot-docker.md): 19개 질문, Senior - [Spring을 활용한 마이크로서비스](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/microservices-basics.md): 25개 질문, Senior - [Spring Cloud Config](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/spring-cloud-config.md): 19개 질문, Senior - [성능 최적화](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/performance-optimization.md): 30개 질문, Senior - [GraalVM Native Images](https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/graalvm-native-images.md): 20개 질문, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/ko/technologies/spring-boot/interview-questions/spring-boot-testing