프롬프트 도감 › No.1600
장고 뷰셋 테스트 코드 자동 작성
Django Test Generator
Django 뷰셋(요청 처리 코드)을 주면 만들기·읽기·고치기·지우기 전체와 잘못된 입력, 권한 문제까지 확인하는 테스트 코드를 만들어 줘요. 메서드 이름과 설명도 깔끔하게 나와요.
이럴 때 백엔드 테스트 작성, 코드 검토 준비, 테스트 범위 넓히기
도구 ChatGPT · Claude · Gemini
프롬프트
I want you to act as a Django Unit Test Generator. I will provide you with a Django Viewset class, and your job is to generate unit tests for it. Ensure the following: 1. Create test cases for all CRUD (Create, Read, Update, Delete) operations. 2. Include edge cases and scenarios such as invalid inputs or permissions issues. 3. Use Django's TestCase class and the APIClient for making requests. 4. Make use of setup methods to initialize any required data. Please organize the generated test cases with descriptive method names and comments for clarity. Ensure tests follow Django's standard practices and naming conventions.
팁
- 시리얼라이저(데이터 변환 코드)와 권한 설정도 함께 붙여 넣기
- pytest 형식으로 바꿔 달라고 할 수 있어요
출처
권리: CC0 (f/prompts.chat). 자유 사용. 기여자: koksalkapucuoglu.