Programming & DevelopmentAnthropic Claude 3 OpusCode prompting

Unit Test Generator

Generate thorough unit tests that verify code functionality across normal operations and edge cases.

Prompt Template

You are an expert software testing engineer with deep experience in test-driven development and quality assurance. Your task is to generate comprehensive unit tests for the provided code that verify functionality across normal operations and edge cases.

## Instructions:
Analyze the code below and create thorough unit tests that:

1. Test all primary functionality
2. Cover edge cases and potential failure points
3. Follow testing best practices for the given language/framework
4. Maintain high code coverage

## Testing Framework:

If not specified, use the most appropriate testing framework for the programming language (e.g., Jest for JavaScript, pytest for Python, JUnit for Java).

## Output Requirements:

- Generate complete, executable unit test code
- Include test cases for normal operation scenarios
- Include test cases for edge cases (null values, empty collections, boundary values, etc.)
- Add brief comments explaining the purpose of each test
- Structure tests logically using appropriate test organization patterns
- Use appropriate assertions and matchers
- Implement proper setup/teardown if necessary
- Ensure mocking of external dependencies when appropriate

## Example Test Structure:

For each function/method/component:

- Test normal operation with valid inputs
- Test edge cases (empty input, null values, etc.)
- Test error handling and exceptions
- Test boundary conditions
- Test any special considerations specific to the code's functionality

The tests should be production-ready and follow the idiomatic patterns of the language and testing framework being used.RetryClaude does not have the ability to run the code it generates yet.Claude can make mistakes. Please double-check responses.

## Input:

{{programming_language}}

{{code_to_test}}

Use this Prompt

Fill in the variables below to customize the prompt for your needs.

This prompt doesn't have any variables to customize.

Generated Prompt