integration-test-expert
E2E 테스트, Flyway vs @Sql 분리, TestRestTemplate 필수. MockMvc 금지. /kb-integration 명령 시 자동 활성화.
When & Why to Use This Skill
This Claude skill serves as a specialized expert for Spring Boot integration testing, enforcing high-fidelity E2E testing standards. It ensures robust software quality by mandating the use of TestRestTemplate over MockMvc, utilizing Testcontainers for real database environments, and strictly separating Flyway schema migrations from SQL test data to maintain environment consistency.
Use Cases
- Scenario 1: Setting up comprehensive E2E tests using @SpringBootTest(RANDOM_PORT) and TestRestTemplate to validate real-world API behavior and network interactions.
- Scenario 2: Managing database state effectively by using Flyway for DDL (schema) and @Sql for DML (test data), ensuring a clean separation of concerns in automated tests.
- Scenario 3: Implementing containerized testing with Testcontainers to run integration tests against a real MySQL database instead of in-memory alternatives.
- Scenario 4: Refactoring legacy test suites to follow strict isolation principles using @Transactional rollbacks and standardized IntegrationTestFixtures for better maintainability.
| name | integration-test-expert |
|---|---|
| description | E2E 테스트, Flyway vs @Sql 분리, TestRestTemplate 필수. MockMvc 금지. /kb-integration 명령 시 자동 활성화. |
| triggers | [/kb-integration, /go, /red, /green, /refactor, /tidy, integration, e2e, testcontainers, flyway] |
Integration Testing 전문가
핵심 원칙 (Zero-Tolerance)
✅ Mandatory
- @SpringBootTest(RANDOM_PORT) - Full Spring context
- TestRestTemplate 필수 - MockMvc 금지
- Flyway (DDL) - Schema 관리 (
CREATE TABLE) - @Sql (DML) - Test data만 (
INSERT) - IntegrationTestFixture 필수 - Inline 객체 생성 금지
- @Transactional + @Rollback - Data isolation
- @Testcontainers - Real database (MySQL)
❌ Prohibited
- DDL in @Sql 금지 - Flyway migration 사용
- MockMvc 금지 - TestRestTemplate 사용
- @WebMvcTest 금지 - @SpringBootTest 사용
- Inline 객체 생성 금지 - IntegrationTestFixture 사용
- Flyway 수정 금지 - Test data는 @Sql에
- Excessive @MockBean 금지 - Real dependencies 사용
- @DirtiesContext 남용 금지 - @Transactional 사용
예시
✅ CORRECT: E2E Test 패턴
@SpringBootTest(webEnvironment = RANDOM_PORT)
@ActiveProfiles("test")
@Testcontainers
@Transactional
@Sql("/sql/orders-test-data.sql") // Test data (DML)
class OrderIntegrationTest extends IntegrationTestSupport {
@Test
void shouldCreateAndGetOrder() {
// Given - Use Fixture
PlaceOrderRequest request = PlaceOrderRequestFixture.create();
// When - 실제 HTTP POST
ResponseEntity<OrderResponse> response = post(
"/api/orders",
request,
OrderResponse.class
);
// Then
assertCreated(response);
}
}
✅ CORRECT: Flyway (DDL) vs @Sql (DML)
-- ✅ Flyway: V1__create_order_table.sql (DDL)
CREATE TABLE IF NOT EXISTS orders (
order_id BIGINT AUTO_INCREMENT PRIMARY KEY,
...
);
-- ✅ @Sql: orders-test-data.sql (DML)
INSERT INTO orders (order_id, customer_id, status, ...)
VALUES (100, 1, 'PENDING', ...);
-- ❌ WRONG: No DDL in @Sql
-- CREATE TABLE orders (...);
참조
- 전체 가이드: Integration Testing Overview
- 상세 규칙 + 템플릿: REFERENCE.md
자동 활성화
/kb-integration /go|red|green|refactor|tidy 실행 시 자동 활성화.