10 KiB
title, source_type, url, archive_url, related_branches, related_projects, tags, created
| title | source_type | url | archive_url | related_branches | related_projects | tags | created | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Spring Boot Testing — Auto-configured Slice Tests (@WebMvcTest / @DataJpaTest) | official-doc | https://docs.spring.io/spring-boot/reference/testing/spring-boot-applications.html |
|
|
|
2026-06-15 |
Spring Boot Testing — Auto-configured Slice Tests (@WebMvcTest / @DataJpaTest)
Layer:
raw/official-docs/— Spring Boot 공식 레퍼런스에서 slice test semantics 의 verbatim 발췌 및 출처 기록. 검증된 요약은/ingest후wiki/concepts/에source-summary-template형식으로 별도 작성. 원본은 raw 에 영구 보관.
Parent / 활용 branch
| Branch | 이 자료가 정당화하는 결정 |
|---|---|
| raw/branch-notes/feature-test-taxonomy-fixture-contract | D7 — slice test 정의 = Spring test slice (@WebMvcTest/@DataJpaTest) 허용하되 hex use-case slice 와 명시 분리, 동일 test class 에 두 slice annotation 혼용 forbidden. 이 공식 문서가 slice semantics(각 slice 가 로드하는 auto-configuration subset / component scan 제한)와 "여러 slice 혼용 미지원" 규칙을 정의한다. |
출처 / Source
- 원본 URL: https://docs.spring.io/spring-boot/reference/testing/spring-boot-applications.html
- 아카이브 URL: (미등록)
- 저자 / 조직: Spring Boot Team (Pivotal / VMware / Broadcom)
- 발행일: 현행 (4.1.x 레퍼런스 기준, 2026-06-15 확인)
- 마지막 확인일: 2026-06-15
왜 저장했는지 / Why archived
feature-test-taxonomy-fixture-contract 의 D7 결정("Spring slice 허용, hex slice 와 분리, 혼용 forbidden") 이 UNSUPPORTED_DECISION 으로 남아 있었다. Spring Boot 공식 레퍼런스가 (1) 각 slice 가 제한된 auto-configuration subset 만 로드하는 semantics, (2) 여러 @…Test annotation 혼용이 명시적으로 미지원임을 직접 정의하므로, D7 의 근거 자료로 등록한다.
핵심 인용 / Key quotes (verbatim, 5문장)
[§Auto-configured Slice Tests] "Each slice restricts component scan to appropriate components and loads a very restricted set of auto-configuration classes. If you need to exclude one of them, most
@…Testannotations provide anexcludeAutoConfigurationattribute. Alternatively, you can use@ImportAutoConfiguration#exclude."
[§Auto-configured Slice Tests — Multiple Slices] "Including multiple "slices" by using several
@…Testannotations in one test is not supported. If you need multiple "slices", pick one of the@…Testannotations and include the@AutoConfigure…annotations of the other "slices" by hand."
[§Auto-configured Spring MVC Tests — @WebMvcTest] "
@WebMvcTestauto-configures the Spring MVC infrastructure and limits scanned beans to@Controller,@ControllerAdvice,@JacksonComponent,@JsonComponent(deprecated),Converter,GenericConverter,Filter,HandlerInterceptor,WebMvcConfigurer,WebMvcRegistrations, andHandlerMethodArgumentResolver."
[§Auto-configured Spring MVC Tests — @WebMvcTest] "Regular
@Componentand@ConfigurationPropertiesbeans are not scanned when the@WebMvcTestannotation is used.@EnableConfigurationPropertiescan be used to include@ConfigurationPropertiesbeans."
[§Using @AutoConfigure… with @SpringBootTest] "It is also possible to use the
@AutoConfigure…annotations with the standard@SpringBootTestannotation. You can use this combination if you are not interested in "slicing" your application but you want some of the auto-configured test beans."
Claims Extracted / 추출된 주장
| Claim ID | Claim (이 자료가 직접 말하는 것) | Evidence quote | Strength | Applies to | Does not prove |
|---|---|---|---|---|---|
| SB-SLICE-C1 | 각 slice test 는 적절한 컴포넌트로만 component scan 을 제한하고, 매우 제한된 auto-configuration 클래스 집합만 로드한다 | [§Auto-configured Slice Tests] "Each slice restricts component scan to appropriate components and loads a very restricted set of auto-configuration classes." | official-vendor-doc |
Spring Boot 의 모든 @…Test slice annotation (Spring Boot 4.1.x 기준) |
어떤 auto-configuration 이 포함/제외되는지 구체 목록 (slice 별로 다름 — @WebMvcTest 는 §SB-SLICE-C3 참조) |
| SB-SLICE-C2 | 하나의 테스트에 여러 @…Test annotation 을 함께 사용하는 것은 지원되지 않는다. 필요 시 하나의 @…Test 를 기준으로 나머지 slice 의 @AutoConfigure… 를 수동으로 추가해야 한다 |
[§Auto-configured Slice Tests — Multiple Slices] "Including multiple "slices" by using several @…Test annotations in one test is not supported. If you need multiple "slices", pick one of the @…Test annotations and include the @AutoConfigure… annotations of the other "slices" by hand." |
official-vendor-doc |
Spring Boot 4.1.x 의 모든 @…Test slice annotation 조합 |
혼용 시 어떤 런타임 오류가 발생하는지 (docs 는 "not supported" 만 명시, 구체 오류 메시지 없음) |
| SB-SLICE-C3 | @WebMvcTest 는 Spring MVC 인프라를 auto-configure 하고 scan 을 @Controller, @ControllerAdvice, @JacksonComponent, @JsonComponent(deprecated), Converter, GenericConverter, Filter, HandlerInterceptor, WebMvcConfigurer, WebMvcRegistrations, HandlerMethodArgumentResolver 로 제한한다 |
[§Auto-configured Spring MVC Tests — @WebMvcTest] "@WebMvcTest auto-configures the Spring MVC infrastructure and limits scanned beans to @Controller, @ControllerAdvice, @JacksonComponent, @JsonComponent (deprecated), Converter, GenericConverter, Filter, HandlerInterceptor, WebMvcConfigurer, WebMvcRegistrations, and HandlerMethodArgumentResolver." |
official-vendor-doc |
@WebMvcTest 를 사용하는 테스트 클래스 (Spring Boot 4.1.x) |
@DataJpaTest 가 scan 하는 bean 목록 (별도 섹션 확인 필요) |
| SB-SLICE-C4 | @WebMvcTest 사용 시 일반 @Component 와 @ConfigurationProperties bean 은 scan 되지 않는다. @EnableConfigurationProperties 를 통해 @ConfigurationProperties bean 을 포함할 수 있다 |
[§Auto-configured Spring MVC Tests — @WebMvcTest] "Regular @Component and @ConfigurationProperties beans are not scanned when the @WebMvcTest annotation is used. @EnableConfigurationProperties can be used to include @ConfigurationProperties beans." |
official-vendor-doc |
@WebMvcTest 를 사용하는 테스트 클래스 |
@DataJpaTest 또는 다른 slice annotation 에서의 @Component 제외 정책 (slice 마다 다를 수 있음) |
| SB-SLICE-C5 | @AutoConfigure… annotation 을 표준 @SpringBootTest 와 함께 사용할 수 있다. 이 조합은 application 을 "slicing" 하지 않고 일부 auto-configured test bean 만 원할 때 사용한다 |
[§Using @AutoConfigure… with @SpringBootTest] "It is also possible to use the @AutoConfigure… annotations with the standard @SpringBootTest annotation. You can use this combination if you are not interested in "slicing" your application but you want some of the auto-configured test beans." |
official-vendor-doc |
@SpringBootTest 와 @AutoConfigure… 조합이 필요한 테스트 |
@SpringBootTest + @AutoConfigure… 가 slice 와 동일한 context isolation 을 제공한다는 보장 없음 (전체 context 로드) |
Usage Boundaries / 적용 경계
- 이 자료가 직접 증명하는 것:
SB-SLICE-C1: 각@…Testslice annotation 이 component scan 과 auto-configuration 을 제한함SB-SLICE-C2: 하나의 테스트 클래스에 여러@…Testannotation 혼용은 Spring Boot 가 공식적으로 지원하지 않음 — D7 의 "혼용 forbidden" 규칙의 직접 근거SB-SLICE-C3:@WebMvcTest가 scan 하는 bean 타입의 완전한 공식 목록SB-SLICE-C4:@WebMvcTest사용 시@Component/@ConfigurationProperties가 자동 제외됨SB-SLICE-C5: slice 없이@SpringBootTest+@AutoConfigure…조합으로 일부 auto-configuration 만 적용 가능
- 이 자료가 증명하지 않는 것:
- hex use-case slice(port + use case + mapper) 와 Spring slice 를 분리해야 한다는 ca-tmpl 특유의 아키텍처 결정 — D7 의 "명시 분리" 규칙은 별도 근거 필요 (hexagonal architecture 공식 문서 또는 팀 컨벤션)
@DataJpaTest가 scan 하는 bean 타입 목록 (본 자료 SB-SLICE-C3 은@WebMvcTest만 다룸)- 혼용 시 발생하는 구체적 런타임 오류 또는 context 확장 동작 (실험 필요)
- 내 프로젝트에 적용하려면 추가 확인이 필요한 것:
- ca-tmpl Spring Boot 버전이 4.1.x 인지 확인 (4.1.x 기준 문서 —
@JsonComponentdeprecated 여부 등 버전별 차이 가능) @WebMvcTest+@AutoConfigureDataJpa조합이 ca-tmpl 의 context 에서 실제로 의도한 동작을 하는지 로컬 테스트 검증
- ca-tmpl Spring Boot 버전이 4.1.x 인지 확인 (4.1.x 기준 문서 —
메모 / Notes
- SB-SLICE-C2 가 D7 의 핵심 근거. "not supported" 는 Spring Boot 공식의 명시적 금지 문구로, ca-tmpl 의 "혼용 forbidden" 정책과 직접 연결된다.
- D7 의 나머지 부분인 "hex use-case slice 와 명시 분리" 는 본 자료로는 증명되지 않는다 — hexagonal architecture 원칙 자료 별도 raw 등록이 필요하다.
@DataJpaTest의 scan 목록은 본 페이지 별도 섹션에 있을 수 있음 — 필요 시 동일 URL 의 JPA 섹션에서 추가 인용 추출 권고.- 추가로 봐야 할 동일 출처 페이지: https://docs.spring.io/spring-boot/reference/testing/spring-boot-applications.html#testing.spring-boot-applications.spring-mvc-tests (WebMvcTest 상세) + JPA 섹션
Related / 관련
- 같은 주제 다른 official-doc: raw/official-docs/test-taxonomy-testcontainers-official, raw/official-docs/test-taxonomy-practical-pyramid-fowler
- 이 자료를 인용한 branch-note: raw/branch-notes/feature-test-taxonomy-fixture-contract
- 이 자료를 인용한 wiki 요약: (생성 시 추가)