{"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/custom-instructions","title":"사용자 지정 지침"},{"href":"/ko/copilot/tutorials/customization-library/custom-instructions/testing-automation","title":"자동화 테스트"}],"documentType":"article"},"body":"# 자동화 테스트\n\n단위 테스트를 작성하기 위한 파일 특정 지침입니다.\n\n> \\[!NOTE]\n>\n> * 이 라이브러리의 예시는 영감을 얻기 위한 것입니다. 프로젝트, 언어, 팀 프로세스에 더 구체적으로 맞게 조정하는 것이 좋습니다.\n> * 특정 언어 및 시나리오에 대한 사용자 지정 지침의 커뮤니티 기여 예시는 [우수한 GitHub Copilot 사용자 지정](https://github.com/github/awesome-copilot/blob/main/docs/README.instructions.md) 리포지토리를 참조하세요.\n> * 사용자 지정 지침을 만드는 플랫폼 또는 IDE에 따라 다양한 범위에서 사용자 지정 지침을 적용할 수 있습니다. 자세한 내용은 \"[GitHub Copilot 응답을 사용자 지정하는 방법에 대한 정보](/ko/copilot/concepts/response-customization)\"을(를) 참조하세요.\n\n> \\[!NOTE]\n>\n> * 이 라이브러리의 예시는 영감을 얻기 위한 것입니다. 프로젝트, 언어, 팀 프로세스에 더 구체적으로 맞게 조정하는 것이 좋습니다.\n> * 특정 언어 및 시나리오에 대한 사용자 지정 지침의 커뮤니티 기여 예시는 [우수한 GitHub Copilot 사용자 지정](https://github.com/github/awesome-copilot/blob/main/docs/README.instructions.md) 리포지토리를 참조하세요.\n> * 사용자 지정 지침을 만드는 플랫폼 또는 IDE에 따라 다양한 범위에서 사용자 지정 지침을 적용할 수 있습니다. 자세한 내용은 \"[GitHub Copilot 응답을 사용자 지정하는 방법에 대한 정보](/ko/copilot/concepts/response-customization)\"을(를) 참조하세요.\n>   이 예시에서는 `python-tests.instructions.md` 필드를 사용하여 리포지토리의 Python 테스트 파일에만 적용되는 경로 특정 `applyTo` 파일을 보여 줍니다.\n\n````text copy\n---\napplyTo: \"tests/**/*.py\"\n---\n\nWhen writing Python tests:\n\n## Test Structure Essentials\n- Use pytest as the primary testing framework\n- Follow AAA pattern: Arrange, Act, Assert\n- Write descriptive test names that explain the behavior being tested\n- Keep tests focused on one specific behavior\n\n## Key Testing Practices\n- Use pytest fixtures for setup and teardown\n- Mock external dependencies (databases, APIs, file operations)\n- Use parameterized tests for testing multiple similar scenarios\n- Test edge cases and error conditions, not just happy paths\n\n## Example Test Pattern\n```python\nimport pytest\nfrom unittest.mock import Mock, patch\n\nclass TestUserService:\n    @pytest.fixture\n    def user_service(self):\n        return UserService()\n\n    @pytest.mark.parametrize(\"invalid_email\", [\"\", \"invalid\", \"@test.com\"])\n    def test_should_reject_invalid_emails(self, user_service, invalid_email):\n        with pytest.raises(ValueError, match=\"Invalid email\"):\n            user_service.create_user({\"email\": invalid_email})\n\n    @patch('src.user_service.email_validator')\n    def test_should_handle_validation_failure(self, mock_validator, user_service):\n        mock_validator.validate.side_effect = ConnectionError()\n\n        with pytest.raises(ConnectionError):\n            user_service.create_user({\"email\": \"test@example.com\"})\n```\n````"}