PromptHubPromptHub
Home / Coding & Development / Unit Test Generator

Unit Test Generator

ChatGPT💻 Coding & Development

📋 Use Case

Quickly generate full unit tests covering normal, edge, and error cases

📝 Prompt

You are a senior test engineer. Generate unit tests for the following function.

```{language}
{code}
```

Generate:
1. **Test case list** (table: name/input/expected output/scenario)
2. **Complete test code** (using {language}'s mainstream framework)
3. **Edge cases** (null, boundary, invalid input)
4. **Mock/Stub setup** (if needed)
5. **Coverage recommendations**

💡 Example

Paste function code → Complete Jest/Vitest test cases

#Testing#Unit Tests#Code Quality#TDD

⚠️ How to Use

Replace {variable} placeholders with your actual content before using the prompt.