{"meta":{"title":"단위 테스트 생성","intro":"코드에 대한 집중적인 단위 테스트를 만듭니다.","product":"GitHub Copilot","breadcrumbs":[{"href":"/ko/copilot","title":"GitHub Copilot"},{"href":"/ko/copilot/tutorials","title":"자습서"},{"href":"/ko/copilot/tutorials/customization-library","title":"사용자 지정 라이브러리"},{"href":"/ko/copilot/tutorials/customization-library/prompt-files","title":"프롬프트 파일"},{"href":"/ko/copilot/tutorials/customization-library/prompt-files/generate-unit-tests","title":"단위 테스트 생성"}],"documentType":"article"},"body":"# 단위 테스트 생성\n\n코드에 대한 집중적인 단위 테스트를 만듭니다.\n\n데이터 재사용가능.copilot.프롬프트-파일-미리보기-노트 %}\n\n이 프롬프트 파일은 실제 테스트 사례와 유지 관리 가능한 코드를 강조하여 특정 함수나 메서드에 대한 집중적인 단위 테스트를 생성합니다.\n\n## 단위 테스트 생성 프롬프트\n\n```text copy\n---\nagent: 'agent'\ndescription: 'Generate unit tests for selected functions or methods'\n---\n\n## Task\n\nAnalyze the selected function/method and generate focused unit tests that thoroughly validate its behavior.\n\n## Test Generation Strategy\n\n1. **Core Functionality Tests**\n   - Test the main purpose/expected behavior\n   - Verify return values with typical inputs\n   - Test with realistic data scenarios\n\n2. **Input Validation Tests**\n   - Test with invalid input types\n   - Test with null/undefined values\n   - Test with empty strings/arrays/objects\n   - Test boundary values (min/max, zero, negative numbers)\n\n3. **Error Handling Tests**\n   - Test expected exceptions are thrown\n   - Verify error messages are meaningful\n   - Test graceful handling of edge cases\n\n4. **Side Effects Tests** (if applicable)\n   - Verify external calls are made correctly\n   - Test state changes\n   - Validate interactions with dependencies\n\n## Test Structure Requirements\n\n- Use existing project testing framework and patterns\n- Follow AAA pattern: Arrange, Act, Assert\n- Write descriptive test names that explain the scenario\n- Group related tests in describe/context blocks\n- Mock external dependencies cleanly\n\nTarget function: ${input:function_name:Which function or method should be tested?}\nTesting framework: ${input:framework:Which framework? (jest/vitest/mocha/pytest/rspec/etc)}\n\n## Guidelines\n\n- Generate 5-8 focused test cases covering the most important scenarios\n- Include realistic test data, not just simple examples\n- Add comments for complex test setup or assertions\n- Ensure tests are independent and can run in any order\n- Focus on testing behavior, not implementation details\n\nCreate tests that give confidence the function works correctly and help catch regressions.\n```\n\n## 이 프롬프트 파일을 사용하는 방법\n\n1. 위의 콘텐츠를 `generate-unit-tests.prompt.md` 폴더에 `.github/prompts`로 저장합니다.\n1. 테스트할 함수가 포함된 코드 파일을 엽니다. 필요에 따라 특정 함수를 강조 표시할 수 있습니다.\n1. Visual Studio Code에서 공동 파일럿 채팅 보기를 표시하고 `/generate-unit-tests`을(를) 입력합니다. 필요에 따라, 예를 들어 `function_name=fetchActivities` 및 `framework=pytest`와(과) 같이 입력하여 대상 함수와 테스트 프레임워크를 지정할 수도 있습니다.\n\n공동 파일럿 채팅"}