본문으로 건너뛰기
Skillpedia
테스트40k · #7431

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가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/github/awesome-copilot/blob/main/skills/spring-boot-testing/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

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

  1. Test Pyramid: Unit (fast) > Slice (focused) > Integration (complete)
  2. Right Tool: Use the narrowest slice that gives you confidence
  3. AssertJ Style: Fluent, readable assertions over verbose matchers
  4. 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

Testing Tools Reference

Assertion Libraries

Testcontainers

Test Data Generation

Performance & Migration

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:

  1. Analyze complexity - If you need more than 5-7 test cases to cover a single method, it's likely too complex
  2. Recommend refactoring - Suggest breaking the code into smaller, focused functions
  3. User decision - If the user agrees to refactor, help identify extraction points
  4. 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.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬