본문으로 건너뛰기
Skillpedia
테스트8.2k · #12542

testing-patterns

하는 일

이 스킬은 AI에게 자동화된 테스트를 작성하는 건전한 원칙을 알려 줍니다. 단위, 통합, 엔드투엔드 테스트와, 목을 쓰는 것이 맞는 경우를 다룹니다. 믿을 수 있는 테스트 모음을 원하는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓새 비즈니스 로직이나 경계 사례를 위한 테스트를 작성해야 할 때.
  • ✓테스트가 느리거나 불안정하거나 외부 서비스에 의존할 때.
  • ✓기능에 어떤 종류의 테스트를 작성할지 정하는 경우.

스킬 링크

https://github.com/vudovn/ag-kit/blob/main/.agents/skills/testing-patterns/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

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

Use this skill to help me: https://github.com/vudovn/ag-kit/blob/main/.agents/skills/testing-patterns/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분.

작동 방식

이 스킬은 테스트 피라미드와 arrange, act, assert 패턴을 설명합니다. AI는 이 아이디어로 테스트 종류를 고르고 각 테스트의 구조를 짭니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Testing Patterns

Principles for reliable test suites.


1. Testing Pyramid

        /\          E2E (Few)
       /  \         Critical flows
      /----\
     /      \       Integration (Some)
    /--------\      API, DB queries
   /          \
  /------------\    Unit (Many)
                    Functions, classes

2. AAA Pattern

Step Purpose
Arrange Set up test data
Act Execute code under test
Assert Verify outcome

3. Test Type Selection

When to Use Each

Type Best For Speed
Unit Pure functions, logic Fast (<100ms)
Integration API, DB, services Medium
E2E Critical user flows Slow

4. Unit Test Principles

Good Unit Tests

Principle Meaning
Fast < 100ms each
Isolated No external deps
Repeatable Same result always
Self-checking No manual verification
Timely Written with code

What to Unit Test

Test Don't Test
Business logic Framework code
Edge cases Third-party libs
Error handling Simple getters

5. Integration Test Principles

What to Test

Area Focus
API endpoints Request/response
Database Queries, transactions
External services Contracts

Setup/Teardown

Phase Action
Before All Connect resources
Before Each Reset state
After Each Clean up
After All Disconnect

6. Mocking Principles

When to Mock

Mock Don't Mock
External APIs The code under test
Database (unit) Simple dependencies
Time/random Pure functions
Network In-memory stores

Mock Types

Type Use
Stub Return fixed values
Spy Track calls
Mock Set expectations
Fake Simplified implementation

7. Test Organization

Naming

Pattern Example
Should behavior "should return error when..."
When condition "when user not found..."
Given-when-then "given X, when Y, then Z"

Grouping

Level Use
describe Group related tests
it/test Individual case
beforeEach Common setup

8. Test Data

Strategies

Approach Use
Factories Generate test data
Fixtures Predefined datasets
Builders Fluent object creation

Principles

  • Use realistic data
  • Randomize non-essential values (faker)
  • Share common fixtures
  • Keep data minimal

9. Best Practices

Practice Why
One assert per test Clear failure reason
Independent tests No order dependency
Fast tests Run frequently
Descriptive names Self-documenting
Clean up Avoid side effects

10. Anti-Patterns

❌ Don't ✅ Do
Test implementation Test behavior
Duplicate test code Use factories
Complex test setup Simplify or split
Ignore flaky tests Fix root cause
Skip cleanup Reset state

Remember: Tests are documentation. If someone can't understand what the code does from the tests, rewrite them.

자주 묻는 질문

테스트 피라미드란 무엇인가요?

대부분의 테스트는 빠른 단위 테스트여야 하고, 그 위에 통합 및 엔드투엔드 테스트가 적어야 한다는 지침입니다.

단위 테스트하지 말아야 할 것은?

프레임워크 코드, 제3자 라이브러리, 단순한 getter는 테스트하지 말라고 스킬이 설명합니다.

좋은 단위 테스트의 조건은?

빠르고, 격리되어 있고, 반복해도 같은 결과가 나오며, 스스로 검사하고, 코드와 함께 작성되어야 합니다.

상세 정보

작성자의 원본 설명

Testing patterns and principles. Unit, integration, mocking strategies.

repo: vudovn/ag-kit

인기도

GitHub 스타
8.2k
순위
#12542
라이선스
MIT
업데이트
2026. 10. 18.

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬