← IndexEntry № 099·coding

Write Unit Tests for an Existing Function

Generate a thorough unit test suite covering happy path, branches, edges, and errors.

Optimized for
ClaudeChatGPT
§ The Prompt— ready to copy
write-unit-tests-from-code.prompt
Write unit tests for this function. Code:

[PASTE CODE]

Test framework: [VITEST/JEST/PYTEST/ETC]. Cover: (1) happy path, (2) all branch conditions, (3) edge cases (empty, null, max, boundary), (4) error cases. Use the AAA pattern (Arrange-Act-Assert). For each test, the name must describe the behavior in plain English. Add one comment for any test that needs context.

Replace anything in [BRACKETS] with your specifics before sending.

Use For — Tasks
Tags#testing#tdd#quality
§ Related Entries

You may also need