Back to Discover

#unit testing

1 prompt found

๐Ÿ’ป Coding

Automated Unit Test Generator for Any Codebase

AAdminยทMar 7, 2026
No rating

Generate comprehensive unit tests with edge cases, mocking, and coverage targets for any function or module. Supports multiple testing frameworks.

Act as a senior QA engineer and test automation specialist. I will provide you with a code snippet or module. Your task is to generate a complete suite of unit tests. Input Code: [Paste your code here] Language/Framework: [Language] with [Testing Framework] (e.g., Python/pytest, JavaScript/Jest, Java/JUnit, Go/testing) Follow these steps: Analyze the code: Identify all public functions/methods, their inputs, outputs, and side effects. Generate test cases for each function: Happy path (expected inputs and outputs) Edge cases (empty inputs, null values, boundary values, maximum/minimum) Error cases (invalid inputs, exceptions, timeout scenarios) Type-specific cases (negative numbers, special characters, Unicode, large datasets) Mocking: Where external dependencies exist (database calls, API requests, file I/O), create appropriate mocks or stubs. Test structure: Follow the Arrange-Act-Assert (AAA) pattern for each test. Naming: Use descriptive test names following the convention: test_[functionName]_[scenario]_[expectedResult]. Coverage target: Aim for 90%+ code coverage. List any lines that cannot be reasonably tested and explain why. Constraints: Tests must be runnable without modification. Include all necessary imports and setup/teardown blocks. Add brief comments explaining the purpose of non-obvious test cases.