spring-boot-testing
하는 일
이 도구는 무엇을 확인하고 싶은지에 따라 가장 알맞은 테스트 방법을 골라 Spring Boot 코드를 테스트하도록 돕습니다. 테스트를 더 쉽고 명확하게 만드는 최신 도구를 사용합니다.
사용하는 경우
- ✓웹사이트의 'endpoint'(통신 포트)가 올바르게 작동하는지 테스트하고 싶을 때.
- ✓프로그램에서 데이터를 저장하고 읽는 부분이 올바른지 확인하고 싶을 때.
- ✓프로그램이 인터넷을 통해 다른 서비스와 어떻게 통신하는지 테스트해야 할 때.
스킬 링크
https://github.com/github/awesome-copilot/blob/main/skills/spring-boot-testing/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“데이터베이스에 데이터를 저장하는 제 코드가 올바르게 작동하는지 어떻게 테스트하나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
도구는 테스트하려는 내용을 분석하고 가장 좋은 접근 방법을 제안합니다. 예를 들어 화면 부분을 테스트하려면 `@WebMvcTest`를, 데이터 부분을 테스트하려면 `@DataJpaTest`를 제안합니다. 또 더 읽기 쉬운 테스트를 쓰기 위해 AssertJ 같은 라이브러리도 권장합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Spring Boot Testing
This skill provides expert guide for testing Spring Boot 4 applications with modern patterns and best practices.
Core Principles
- Test Pyramid: Unit (fast) > Slice (focused) > Integration (complete)
- Right Tool: Use the narrowest slice that gives you confidence
- AssertJ Style: Fluent, readable assertions over verbose matchers
- Modern APIs: Prefer MockMvcTester and RestTestClient over legacy alternatives
Which Test Slice?
| Scenario | Annotation | Reference |
|---|---|---|
| Controller + HTTP semantics | @WebMvcTest |
references/webmvctest.md |
| Repository + JPA queries | @DataJpaTest |
references/datajpatest.md |
| REST client + external APIs | @RestClientTest |
references/restclienttest.md |
| JSON (de)serialization | @JsonTest |
references/test-slices-overview.md |
| Full application | @SpringBootTest |
references/test-slices-overview.md |
Test Slices Reference
- references/test-slices-overview.md - Decision matrix and comparison
- references/webmvctest.md - Web layer with MockMvc
- references/datajpatest.md - Data layer with Testcontainers
- references/restclienttest.md - REST client testing
Testing Tools Reference
- references/mockmvc-tester.md - AssertJ-style MockMvc (3.2+)
- references/mockmvc-classic.md - Traditional MockMvc (pre-3.2)
- references/resttestclient.md - Spring Boot 4+ REST client
- references/mockitobean.md - Mocking dependencies
Assertion Libraries
- references/assertj-basics.md - Scalars, strings, booleans, dates
- references/assertj-collections.md - Lists, Sets, Maps, arrays
Testcontainers
- references/testcontainers-jdbc.md - PostgreSQL, MySQL, etc.
Test Data Generation
- references/instancio.md - Generate complex test objects (3+ properties)
Performance & Migration
- references/context-caching.md - Speed up test suites
- references/sb4-migration.md - Spring Boot 4.0 changes
Quick Decision Tree
Testing a controller endpoint?
Yes → @WebMvcTest with MockMvcTester
Testing repository queries?
Yes → @DataJpaTest with Testcontainers (real DB)
Testing business logic in service?
Yes → Plain JUnit + Mockito (no Spring context)
Testing external API client?
Yes → @RestClientTest with MockRestServiceServer
Testing JSON mapping?
Yes → @JsonTest
Need full integration test?
Yes → @SpringBootTest with minimal context config
Spring Boot 4 Highlights
- RestTestClient: Modern alternative to TestRestTemplate
- @MockitoBean: Replaces @MockBean (deprecated)
- MockMvcTester: AssertJ-style assertions for web tests
- Modular starters: Technology-specific test starters
- Context pausing: Automatic pausing of cached contexts (Spring Framework 7)
Testing Best Practices
Code Complexity Assessment
When a method or class is too complex to test effectively:
- Analyze complexity - If you need more than 5-7 test cases to cover a single method, it's likely too complex
- Recommend refactoring - Suggest breaking the code into smaller, focused functions
- User decision - If the user agrees to refactor, help identify extraction points
- Proceed if needed - If the user decides to continue with the complex code, implement tests despite the difficulty
Example of refactoring recommendation:
// Before: Complex method hard to test
public Order processOrder(OrderRequest request) {
// Validation, discount calculation, payment, inventory, notification...
// 50+ lines of mixed concerns
}
// After: Refactored into testable units
public Order processOrder(OrderRequest request) {
validateOrder(request);
var order = createOrder(request);
applyDiscount(order);
processPayment(order);
updateInventory(order);
sendNotification(order);
return order;
}
Avoid Code Redundancy
…
자주 묻는 질문
'테스트 피라미드'란 무엇인가요?
테스트를 정리하는 방법입니다. 작고 빠른 테스트(단위)를 많이, 중간 규모 테스트(슬라이스)를 일부, 크고 느린 테스트(통합)를 적게 둡니다.
AssertJ는 왜 쓰나요?
AssertJ는 더 자연스러운 언어로 결과가 맞는지 확인하게 해 주어, 테스트를 읽고 쓰기 쉽게 만듭니다.
'테스트 슬라이스'란 무엇인가요?
애플리케이션의 특정 부분, 예를 들어 네트워크 계층이나 데이터 계층만 집중해서 테스트하는 것입니다. 테스트를 더 빠르고 정확하게 만듭니다.
상세 정보
작성자의 원본 설명
Expert Spring Boot 4 testing specialist that selects the best Spring Boot testing techniques for your situation with Junit 6 and AssertJ.
repo: github/awesome-copilot
인기도
- GitHub 스타
- 40k
- 순위
- #7431
- 라이선스
- MIT
- 업데이트
- 2026. 10. 15.
댓글
- …
이 저장소의 다른 스킬
acquire-codebase-knowledge
40k에이전트가 기존 코드 프로젝트를 이해하고 문서화하도록 돕습니다. 새 구성원을 맞이하거나 아키텍처를 개괄적으로 파악할 때 유용합니다.
acreadiness-assess
40k에이전트가 프로젝트의 AI 준비 상태를 평가하고 보고서를 만들도록 합니다. 프로젝트가 AI 도구를 쓸 준비가 얼마나 되어 있는지 이해하는 데 유용합니다.
acreadiness-generate-instructions
40k에이전트가 평가 결과를 바탕으로 AI 도구를 위한 지침을 만들도록 돕습니다. AI가 코드와 상호작용하는 방식을 개선하고 확인된 공백을 메울 때 유용합니다.
acreadiness-policy
40k에이전트가 AI 프로젝트 평가를 위한 정책을 정의하거나 적용하도록 돕습니다. 프로젝트 평가 방식을 표준화하고 규정 준수를 보장할 때 유용합니다.
비슷한 스킬
test-driven-development
311k에이전트가 기능이나 수정을 만들기 전에 실패하는 테스트를 먼저 쓰고, 그것을 통과시키는 가장 작은 코드를 작성하도록 가르칩니다.
verification-before-completion
311k에이전트가 작업, 수정, 빌드가 완료되었거나 통과했다고 말하기 전에 실제 점검을 실행하고 결과를 읽도록 가르칩니다.
migrate-to-shoehorn
310k테스트 파일의 위험한 타입 캐스팅을 shoehorn 라이브러리로 바꿔, 테스트가 일부 데이터만 써도 타입 검사를 통과하도록 돕습니다.