AI Prompts Library
Curated collection of expert prompts for coding, writing, marketing, image generation, and more
Have a great prompt? Submit it to the library →
Popular Tags:
Coding
Test Case Generator for Unit and Integration Tests
Optimized for: general • TEXT
You are a senior QA engineer and testing expert. Generate comprehensive test cases for the given code or feature. Cover unit tests, integration tests, and edge cases. **Code/Feature to Test:** [PASTE CODE OR DESCRIBE FEATURE] **Tech Stack:** [e.g., Jest/Vitest + React Testing Library, Pytest, Go testing, JUnit] **Test Runner:** [e.g., Jest, Vitest, Pytest, Go test] **Generate tests following this structure:** 1. **Unit Tests** (isolated, fast, no external dependencies): - Happy path: Test normal expected behavior with valid inputs - Edge cases: Empty strings, null/undefined, zero, negative numbers, max values - Boundary conditions: Off-by-one errors, array bounds, string length limits - Type variations: Different input types that should be handled - Error cases: Invalid inputs that should throw specific errors 2. **Integration Tests** (test component interactions): - API calls: Mock HTTP requests, test loading/error/success states - Database operations: Test CRUD with test database or in-memory DB - Component integration: Test parent-child component communication - Service layer: Test business logic with mocked dependencies 3. **Test Organization:** - Use describe blocks to group related tests - Use clear test names: 'should [expected behavior] when [condition]' - Setup and teardown with beforeEach/afterEach - Shared fixtures and test data factories - Test isolation: Each test must be independent 4. **Mocking Strategy:** - Identify all external dependencies to mock - Create typed mock factories - Verify mock calls (called with correct arguments, correct number of times) - Reset mocks between tests 5. **Coverage Goals:** - Line coverage: > 90% - Branch coverage: > 85% - Identify untestable code and suggest refactoring **Output**: Complete test file(s) ready to run, with comments explaining the reasoning behind each test case.
Writing test suites for new features, improving test coverage, establishing testing patterns
No Prompts Found
Try adjusting your filters or search query.
Want Custom Prompts?
Get personalized AI prompts tailored to your specific needs and workflow.
Contact Us