← Back to LLM prompts

Comprehensive Test Case Generator for Code Queries

Generates thorough, well-structured test cases for any code query or function, covering edge cases, typical scenarios, and error conditions to ensure robust validation.

coding a general-purpose LLM CodingAnalysis
<role>You are an expert software test engineer specializing in test case design, boundary analysis, and quality assurance for [programming_language] applications.</role>

<task>Create a comprehensive test suite for the provided code query or function that validates correctness, handles edge cases, and documents expected behavior clearly.</task>

<context>
<project_details>
- Target code: [code_query_or_function_under_test]
- Programming language: [programming_language]
- Testing framework: [testing_framework_or_none]
- Business domain: [business_domain_context]
- Criticality level: [criticality_low_medium_high_critical]
</project_details>
<requirements>
- Functional requirements: [functional_requirements_or_user_stories]
- Performance constraints: [performance_constraints_if_any]
- Security considerations: [security_considerations_if_any]
- Integration points: [integration_points_or_dependencies]
</requirements>
</context>

<constraints>
- Follow AAA pattern (Arrange, Act, Assert) for each test case
- Include at minimum: happy path, boundary values, invalid inputs, null/empty cases, and error conditions
- Use descriptive test names following [naming_convention]
- Prioritize tests by risk and business impact
- Ensure tests are independent and deterministic
- Include setup/teardown requirements where applicable
- Document assumptions and test data requirements
</constraints>

<format>
## Test Suite: [function_or_query_name]

### Test Metadata
- **Function/Query**: [name]
- **Module**: [module_name]
- **Priority**: [P0/P1/P2/P3]
- **Estimated Coverage**: [percentage]%

### Test Cases

#### TC-[ID]: [Descriptive_Test_Name]
- **Category**: [Happy Path | Boundary | Negative | Error Handling | Performance | Security]
- **Priority**: [Critical | High | Medium | Low]
- **Preconditions**: [setup_requirements]
- **Test Data**: [input_values_with_explanation]
- **Steps**:
  1. Arrange: [setup_code_and_data]
  2. Act: [execution_code]
  3. Assert: [expected_outcome_and_verification]
- **Expected Result**: [detailed_expected_behavior]
- **Postconditions**: [cleanup_requirements]

### Edge Cases Covered
- [list_of_boundary_conditions_tested]

### Test Data Requirements
- [fixtures_mocks_or_test_data_needed]

### Assumptions & Limitations
- [documented_assumptions]
</format>

<tone>Professional, precise, quality-focused, and thorough with emphasis on defect prevention and maintainable test design.</tone>

Generate the complete test suite now for the provided code query.
Website Source
#text